First-class RTL support
Core has first-class RTL support for Arabic, Hebrew, Persian (Farsi) and Urdu. There is no second stylesheet and no RTL build. The same CSS follows the direction of the page, because the logical classes and mixins write logical properties (inline start and end) instead of left and right.
Switch direction
Section titled “Switch direction”Set dir="rtl" and a lang on the <html> element. Use lang="ar" for Arabic, lang="he" for Hebrew, lang="fa" for Persian and lang="ur" for Urdu.
<html lang="ar" dir="rtl">A single section can switch on its own, such as an Arabic panel in an English page:
<section lang="he" dir="rtl">...</section>Everything inside the section follows its direction.
Logical classes
Section titled “Logical classes”Under dir="rtl" the inline start is the right side, so ps-4 pads the right edge and border-s-4 draws the right border. Write the logical class and the page works in both directions.
Logical (mirrors under dir="rtl") |
Physical (keeps its side) |
|---|---|
ps-*, pe-*, px-* |
pl-*, pr-* |
ms-*, me-*, mx-*, ms-auto, me-auto, mx-auto |
ml-*, mr-* |
start-*, end-* |
left-*, right-*, inset-x-* |
border-s, border-e, border-s-{w}, border-e-{w} |
border-l, border-r, border-x |
rounded-s-*, rounded-e-*, rounded-ss-*, rounded-se-*, rounded-es-*, rounded-ee-* |
rounded-l-*, rounded-r-*, rounded-tl-* and the other corners |
text-start, text-end |
text-left, text-right |
space-x-* |
<div class="flex x-center gap-3 ps-4 pe-2 py-3 border-s-4 border-brand rounded-s-md bg-brand-subtle text-start"> <span>تم حفظ التغييرات بنجاح</span> <span class="ms-auto text-muted">الآن</span></div>The accent border, the rounded corners, the start padding and the pushed-away time all move to the other side in the RTL preview. The spacing scale and every logical class are listed in Spacing.
Logical mixins
Section titled “Logical mixins”The same names work in apply(). They compile to logical properties, so the output needs no [dir="rtl"] overrides.
| Mixin | Output |
|---|---|
ps(), pe() |
padding-inline-start, padding-inline-end |
ms(), me() |
margin-inline-start, margin-inline-end |
inset-start(), inset-end() |
inset-inline-start, inset-inline-end |
border-start(), border-end() |
border-inline-start-*, border-inline-end-* |
rounded-s(), rounded-e() |
the start and end corner radii |
text-start, text-end |
text-align: start, text-align: end |
@use "@wovenui/core" as *;
.row { @include apply(flex, x-center, gap(3), ps(4), pe(2), py(2), border-start(4, solid, brand), text-start, bg(surface));}.row__time { @include apply(ms-auto, text-color(muted));}<div class="row" lang="he"> <span>חשבונית חדשה נוצרה</span> <span class="row__time">לפני שעה</span></div>.row { display: flex; align-items: center; gap: var(--wu-space-3);}.row > * { --wu-gap: var(--wu-space-3);}.row { padding-inline-start: var(--wu-space-4); padding-inline-end: var(--wu-space-2); padding-block: var(--wu-space-2); border-inline-start-width: var(--wu-border-width-4); border-inline-start-style: var(--wu-border-style); border-inline-start-color: var(--wu-brand); --wu-border-style: solid; text-align: start; background-color: var(--wu-bg-surface);}
.row__time { margin-inline-start: auto; color: var(--wu-text-muted);}Keep a side on purpose
Section titled “Keep a side on purpose”Some content must stay on one side of the screen whatever the language: a close button pinned to the top right corner of a viewer, a horizontal chart axis, a media control bar. Use the physical classes (left-*, right-*, pl-*, pr-*, text-left) or mixins (left(), right()) for those. Everything that follows the reading order, such as a sidebar accent, an icon after a label or indented text, stays logical.
px, mx and space-x are logical. inset-x-* and border-x are the physical exceptions: they write left and right.
لديك ثلاث رسائل جديدة في صندوق الوارد
لديك ثلاث رسائل جديدة في صندوق الوارد
<div class="relative p-4 border rounded-md bg-surface"> <span class="absolute top-2 right-2 px-2 rounded-full bg-brand-subtle text-brand">3</span> <p class="pe-6 text-start" lang="ar">لديك ثلاث رسائل جديدة في صندوق الوارد</p></div>Your own directional icons
Section titled “Your own directional icons”Icons are yours, so core cannot know which ones point somewhere. Flip back, next and arrow icons in RTL, and leave symmetric icons (a search lens, a gear), logos and clocks alone.
WovenUI Components ships a wu-mirror class for this, see the components RTL page. In your own CSS, .back-icon below stands for your own class:
.back-icon:dir(rtl) { scale: -1 1;}Mixed content
Section titled “Mixed content”Emails, URLs, product codes and numbers run left to right inside right-to-left text. Two habits keep them readable:
- Wrap an inline name or value of unknown direction in
<bdi>, so its direction cannot disturb the text around it. - Give inputs for emails, URLs and codes
dir="ltr", and keep them aligned to the start of the field.
تمت دعوة Sara Ahmed (QA) إلى فريق المشروع.
<div lang="ar" dir="rtl" class="flex col gap-3"> <p>تمت دعوة <bdi>Sara Ahmed (QA)</bdi> إلى فريق المشروع.</p> <label for="rtl-core-email">البريد الإلكتروني</label></div>- The Arabic and Hebrew copy in these demos has not been reviewed by native speakers yet. Treat it as sample text.
- Core ships no fonts. Persian and Urdu often look best in a typeface made for them (Urdu in a Nastaliq style), which you load yourself.
- Tooltip positions are physical:
data-tooltip-position="left"is always the left side of the screen. See Tooltips. - The base layer is logical too: blockquotes take
border-inline-start, and checkboxes and radios takemargin-inline-end. - Focus, contrast and motion are covered on Accessibility.