Skip to content
Back to blog

Engineering

How to Build an RTL-First Design System

Reading time
8 min read
Published
Last updated
How to Build an RTL-First Design System

Five decisions let a component work right to left without overrides. This guide adds a mirroring table, a test matrix that covers exports and examples from ClinicTek's code.

An RTL-first design system settles each right-to-left decision once, inside the component, so an Arabic page needs no overrides. Five decisions carry most of the work. Set direction at the document root, use logical CSS properties, write an icon mirroring policy, isolate mixed-direction text and tune type for each script. A test matrix that runs both directions and covers exports keeps those decisions from drifting.

The examples below come from the code of barmajtek.com and of ClinicTek, the clinic management system we build and run.

What dir="rtl" does, and what it leaves to your components

Setting dir="rtl" on the <html> element makes the right edge the start of every line. Paragraphs align right, table columns run right to left, form input starts at the right, and spacing written with logical properties mirrors on its own.

W3C's internationalization guidance says to set base direction in the markup, never in CSS. The page then reads correctly even if the stylesheet fails to load. Declare lang as well. It names the language for fonts, hyphenation and screen readers, and only dir sets direction.

Four other choices stay with your components. They cover which icons flip and how an invoice number or email sits inside an Arabic sentence. They also cover whether a chart axis reverses and how text behaves in a PDF, an email or a CSV file.

Replace physical properties with logical ones

Logical properties describe layout by the flow of text. Inline is the direction a line of text runs, and block is the direction lines stack. margin-inline-start is the left margin in English and the right margin in Arabic, so one stylesheet serves both.

Article data table: Replace physical properties with logical ones (1)
Physical (avoid)Logical (use)
margin-leftmargin-inline-start
padding-rightpadding-inline-end
left: 0 on a positioned elementinset-inline-start: 0
text-align: lefttext-align: start
border-top-left-radiusborder-start-start-radius

Name design tokens by purpose, such as --space-field-gap, and never by side. Then review transforms and absolute positioning, because physical assumptions often survive there after you convert the spacing. Flex and grid already follow reading order, so leave their direction alone unless the sequence has a fixed meaning.

Decide which icons mirror, and store the decision in the component

This table is our rule of thumb. Check each icon against what it means in your product.

Article data table: Decide which icons mirror, and store the decision in the component (2)
MirrorKeep as drawnDecide by meaning
Back and next arrowsLogos and brand marksProgress steps inside a chart
Breadcrumb and list chevronsPlay, pause and other media controlsTimelines
Progress bars and slidersClocks, phones, check marksIcons that show a physical object with a side

Keep the rule in one place. On barmajtek.com, the shared button component adds the Tailwind class rtl:rotate-180 only when its icon is the arrow. The class turns the icon half a turn on right-to-left pages, and every other icon keeps its orientation. Breadcrumb separators and the arrow on the FAQ block's contact link carry the same class in their own components. No page adds it by hand.

Pair important icons with text or an accessible name. ClinicTek's invoice strip hides the patient and file icons from screen readers, and each value carries a visually hidden label. A screen reader announces each label with its value, whatever the icon's position. After mirroring, check that keyboard focus moves in the same direction as the eye.

Isolate mixed-direction text

Arabic sentences carry English product names, emails, URLs, codes and numbers. Wrap each run whose direction you cannot predict in <bdi>, the HTML element that isolates text from its surroundings, or give its wrapper dir="auto". W3C recommends markup over Unicode direction control characters and keeps those characters for places where markup cannot go, such as a title attribute. Never store control characters in your data to fix a display. They are invisible in review, and they travel into every export.

ClinicTek shows the pattern in three places. The invoice strip puts the patient file number and the invoice number each in its own dir="ltr" span. Each reference keeps its order inside an Arabic line. The email verification screen wraps the address in <bdi dir="ltr">. In the equipment form, serial number, date and cost fields take dir="ltr" while their labels stay right to left.

Digits need the same care. W3C's Arabic layout requirements note that numbers are written left to right inside Arabic text, whichever digit shapes you use. Test phone numbers, prices with a currency and ranges such as "2-5" in a right-to-left sentence.

Set type for each script

Arabic and Latin fonts differ in vertical metrics, perceived size, weight and the line height they need. Choose fonts with real coverage of Arabic glyphs, diacritics, numerals and bold weights, then test them. Forcing identical pixel metrics on both scripts clips Arabic marks or misaligns controls. Let labels wrap and buttons grow, and test browser zoom and the operating system's font scaling. A screenshot with short labels proves little about a component that will hold real Arabic copy.

Keep source order and accessibility intact

Write the DOM in the order a person reads and tabs through it, then let direction handle the visual flow. Avoid order and absolute positioning that make the spoken sequence differ from the screen. In data tables, keep header associations explicit and test horizontal scrolling from the logical start. Put error messages next to their fields. Verify focus rings, menus, dialogs and carousels in both directions, with the keyboard as well as the mouse.

Write content as whole messages

Give writers complete messages with context. Fragments joined in code follow English word order and break in Arabic, especially where a number and a noun meet. Use your localization library's plural and formatting rules. Set a character limit only where the layout has a real constraint, and redesign the component when the meaning does not fit. Write SEO titles and descriptions natively for each language, because a translated heading makes poor search copy.

Decide chart, map and timeline direction by meaning

A time series may follow the reading direction. Do not mirror a map or its coordinates. Axes, legends, tooltips and keyboard order each need a written decision. Before you apply scaleX(-1), ask what the direction represents. The transform also mirrors any text and hit areas inside the element.

Test both directions with one matrix

Run each high-risk component through the same six cases in Arabic and in English. Use long Arabic text, a Latin name inside Arabic, numbers and currency, an error state, keyboard only and 200% zoom.

Article data table: Test both directions with one matrix (3)
ComponentWhat to look for
Data tableColumn order, sticky columns, horizontal scroll start, sorted numbers
Field with mixed textCaret position, punctuation around Latin runs, error message placement
Dropdown and menuOpening side, arrow keys, truncation at the logical end
Toast and alertIcon side, close button side, reading order for screen readers
Printed page or PDFEmbedded Arabic font, digit order, table direction
EmailDirection of the body, product names and links inside Arabic lines
CSV exportUTF-8 encoding, Arabic names intact in a spreadsheet, no stored control characters

Record the expected behaviour in a component story or a visual test, so a redesign does not reopen the decision.

Move an existing library to RTL-first

  1. Add a lint rule or review check that flags new physical properties such as margin-left, left: and text-align: left. Keep a written list of justified exceptions.
  2. Convert the most-used components first: buttons, fields, tables, menus and dialogs.
  3. Run each converted component through the matrix and remove its RTL overrides once it passes.
  4. Log defects by pattern (mixed text, icon, source order, clipping) so each fix lands in the component.
  5. Ask for an Arabic and an English screenshot in every component review.

For a checklist with stable IDs for both language editions, use the Arabic-first interface QA kit. Why we design Arabic-first covers the product reasoning, and the Flutter and Laravel guide shows why language belongs in the API contract too.

If you want us to review an existing component library against this matrix, send a short project brief or message us with the WhatsApp button on this page.

Frequently asked questions

Either is correct. Pick one per product and apply it everywhere through JavaScript's `Intl` API with an explicit numbering system, for example `ar-u-nu-latn` for Western digits. Our clinic, gym and teaching products use Western digits (0-9). Both kinds of digits run left to right inside Arabic text, so the isolation rules above apply either way.

Sources

#Architecture #RTL

Read our editorial policy

Building a custom system for your business?

After “How to Build an RTL-First Design System”: tell us scope, users, and integrations — we reply with a practical plan after reviewing your request.