Alternative implementation · Prototype available
Logical properties for RTL support
Replace selected physical left/right styles in the banner and alert with logical properties so right-to-left layouts do not depend on mirrored overrides.
Working demonstration
Evaluate this experiment Open the registered demonstration
- Banner — baseline and experimental fixtures available.
- Alert — baseline and experimental fixtures available.
The evaluation workspace does not mirror keyboard input. Open either implementation independently for keyboard and assistive-technology testing.
Proposal and context
Status: Prototype. Automated evidence may exist; human review is pending.
Category: Alternative implementation
Baseline: USWDS v3.14.0
Proposal: Use logical properties for the banner and alert instead of mirrored physical overrides.
Why this exists
USWDS issue #5336 remains open. Maintainers asked for a concrete RTL example and LTR compatibility checks. Issue #6030 prototyped logical properties for the banner and was consolidated into #5336.
RTL support is not the same as flipping the page. Text direction, language, logical padding, icon placement, focus order, and content order must remain meaningful.
What stable USWDS provides
USWDS uses a mix of logical and physical properties. Some components already respond to dir="rtl", but the alert's accent border and some alignment details need explicit review. The lab does not claim that the whole design system is RTL-ready.
What is proposed
The experimental stylesheet:
- replaces the alert's physical left border with
border-inline-start; - sets
text-align:starton accordion and banner buttons; - keeps the document's
langanddirseparate: direction is not a translation; - adds a small sample Arabic paragraph with
lang="ar" dir="rtl"to test mixed-direction content.
What changed in the lab
Only the experimental pane changes. The baseline keeps the official output. The same English fixture content is used in both panes, plus the labelled Arabic sample.
Evidence status
Automated evidence covers ?dir=rtl on the banner and alert fixtures, computed text-align and border sides, and the mixed-direction sample. Native-language review is outstanding. The decision record is pending.
Known limitations
- The Arabic sample is short and was written for direction testing; a native speaker has not reviewed it.
- This is not a translation or a full localization implementation.
- The lab does not test every USWDS component or browser bidi algorithm edge case.
- Icon mirroring, focused-element placement, and long mixed-direction forms need further work.
Implementation guidance
CSS
.usa-alert {
border-left: 0 !important;
border-right: 0 !important;
border-inline-start: 8px solid var(--fx-info-edge) !important;
text-align: start;
}
.usa-alert--warning { border-inline-start-color: var(--fx-warn-edge) !important; }
.usa-alert--error { border-inline-start-color: var(--fx-error-edge) !important; }
.usa-accordion__button,
.usa-banner__button,
.usa-banner__header-text,
.usa-banner__header-action { text-align: start; }
border-inline-start resolves to border-left in ltr and border-right in rtl. The physical border-left/border-right declarations are removed so the two rules cannot disagree.
Direction and language
site/assets/fixture.js sets dir from ?dir=rtl and only sets lang="ar" when explicitly requested with ?lang=ar. The banner fixture includes:
<p lang="ar" dir="rtl">معلومات الخدمة …</p>
The inline lang and dir keep the sample from changing the language of the surrounding English page. Do not set dir="rtl" on an English page and call that localization.
How to test
fixture/banner-experiment.html?dir=rtlfixture/alert-experiment.html?dir=rtlcompare.html?component=banner&direction=rtl- Inspect computed
text-align,border-left-width, andborder-right-width. - Tab through the banner: the disclosure button and focus ring should remain visible.
- Confirm the Arabic sample has
lang="ar"anddir="rtl".
What a real contribution would need
- A component-by-component audit of physical properties.
- Native-language review and longer mixed-direction content.
- LTR regression screenshots and tests.
- Documentation of where logical properties cannot be used because of upstream constraints.
- A decision about icon mirroring and focus placement.
Known gaps
- No native Arabic review.
- No full page translation.
- No visual regression baseline; the lab records screenshots and computed properties.
Evidence and limitations
5 of 5 routes collected. Human review pending.
Open the evidence index for transcripts, screenshots, axe observations, and coverage gaps.
Automated evidence is not human approval. The decision record remains authoritative.
Related USWDS history
- #5336 Logical properties for multilingual support (motivation)
- #6030 Banner logical properties (consolidated-prototype)
Experiment files
AI assistance disclosed by the contributor: issue research, initial CSS, test scaffolding, documentation drafting. A human reviewer must assess the evidence before any upstream proposal.