Skip to content

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.

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.

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-*
An Arabic note with a start accent, rendered in LTR and RTL
LTR
تم حفظ التغييرات بنجاح الآن
RTL
تم حفظ التغييرات بنجاح الآن
<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.

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
A Hebrew list row built with logical mixins, rendered in LTR and RTL
LTR
חשבונית חדשה נוצרה לפני שעה
RTL
חשבונית חדשה נוצרה לפני שעה
@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));
}

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.

A pinned corner badge stays right while the text follows the direction
LTR
3

لديك ثلاث رسائل جديدة في صندوق الوارد

RTL
3

لديك ثلاث رسائل جديدة في صندوق الوارد

<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>

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;
}

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.
A name in <bdi> and an LTR email field inside an Arabic block

تمت دعوة 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>
<input id="rtl-core-email" type="email" dir="ltr" value="[email protected]">
</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 take margin-inline-end.
  • Focus, contrast and motion are covered on Accessibility.