Skip to content
Browse docs and components

Going further

RTL Support

How Forme handles right-to-left languages, which properties mirror, and the two places that deliberately do not.

3 min read · 5 sections

Forme mirrors under dir="rtl" with no per-component work and no rtl: variants. That is a consequence of writing logical properties rather than physical ones, and it is worth knowing which is which before you add a component.

Turn it on#

Set the attribute on the document, with a matching lang:

tsx
<html lang="ar" dir="rtl">

Nothing else. There is no provider, no theme flag and no build step, because there is no layout that has to be told twice.

What mirrors#

Instead ofUseMirrors
ml-2 mr-2ms-2 me-2Yes
pl-3 pr-3ps-3 pe-3Yes
left-3 right-3start-3 end-3Yes
text-left text-righttext-start text-endYes
rounded-l-lg rounded-r-lgrounded-s-lg rounded-e-lgYes
border-l border-rborder-s border-eYes

justify-between, justify-end and the flex and grid defaults are already logical: flex-end means the inline end, which is the left in RTL. You do not need rtl:flex-row-reverse.

The clearest place to see it is Input. A leading icon sits at the start of the field and a trailing control at the end, in both directions — so in Arabic the envelope moves to the right and the reveal-password toggle moves to the left, without a variant.

Two things that stay physical#

Both are commented in the source, and both are correct.

Centring. The command menu uses left-1/2 with -translate-x-1/2. Both halves are direction-agnostic: left is the physical left in either direction, and the translate moves the same way, so the panel is centred correctly. There is nothing to mirror.

Chart and canvas geometry. The bar chart anchors its y-axis labels to the plot's right edge, because that is where the axis is drawn. Measured geometry keeps its coordinates; mirroring it would put the labels where the axis is not.

This is the general rule for anything plotted. If you add a chart, measure first.

Mixing directions#

A value that is always written left to right needs an LTR island, or it drags the field it sits in out of alignment:

tsx
// An email address inside an RTL paragraph.
<bdi dir="ltr">hello@example.com</bdi>

Keep these LTR explicitly: email addresses, URLs, code, phone numbers, and OTP digits.

Numbers are subtler. Digits themselves are LTR, but a sequence of them inside RTL text needs isolation too — a price like 1,234 next to an Arabic label will reorder its punctuation without it. Use dir="ltr" on the numeric run.

Note that a component library mirroring correctly does not make the language correct. Chinese is left to right. Locale-aware date and number formatting is your code's job, not the layout's.

Adding a component#

Write logical properties from the start. The review grep in Agent Skills catches the ones that slip through:

bash
git diff -U0 | grep -nE '(^|["'"'"' ])(ml|mr|pl|pr|left|right)-[a-z0-9]'

A physical property is a bug the moment somebody sets dir="rtl", and it is invisible in an English screenshot.