Skip to the content
Documentation
Help Start
Reading in:
  • German: 9,155 of 9,155 pages
About the help in other languages
All help pages

Right-to-left designs

Making a design work for Arabic, Hebrew, Persian and other right-to-left languages: where the direction comes from ($site.text_direction, the locale files), dir on html, logical CSS properties, mirror rules, which icons…

Download as PDF

Address: https://doc.exponential.earth/exphelp/viewer/help/designers/theme-design/right-to-left-designs.md

On this page

Right-to-left designs

This page is for designers who make a design work in right-to-left languages. The administration does it already (since 6.0.15); its rules apply to any design. The full feature description is Right-to-left languages in the administration.

Contents

  1. Where the direction comes from
  2. The page frame
  3. The four CSS rules
  4. Content in another direction
  5. Names inside text
  6. Testing

Where the direction comes from

  • share/locale/<locale>.ini, [LanguageSettings] TextDirection=rtl is the only source; 43 locale files carry it.
  • In templates, $site.text_direction is rtl or ltr for the current interface locale (set by the kernel for every page), and a locale object has text_direction and is_right_to_left.

The page frame

Print dir="rtl" only for a right-to-left language, so left-to-right pages stay byte for byte the same:

<html lang="{$site.http_equiv.Content-language|wash}"{if eq( first_set( $site.text_direction, 'ltr' ), 'rtl' )} dir="rtl"{/if}>

Every administration pagelayout uses exactly this line. first_set() keeps the page working on a kernel without the variable.

The four CSS rules

  1. Logical properties for layout: margin-inline-start, padding-inline-end, inset-inline-start, border-inline-start, text-align: start, the logical corner radii. Left to right they equal the physical ones; right to left they swap by themselves (Logical CSS properties).

  2. A mirror rule where no logical property exists (four-value shorthands with different sides, float, background-position, horizontal shadows), right after the rule it mirrors:

    .x { margin: 0 4px 0 12px; }
    :where([dir="rtl"]) .x { margin: 0 12px 0 4px; }

    :where() adds no specificity, so the mirror wins and loses exactly where the original does.

  3. Flip only icons that point along the line: arrows, chevrons, carets, reply, sign-out. admin4 uses scale: -1 1 on those .a4-bi-* icons. A check mark, a clock or a logo is never flipped.

  4. Do not mirror alignment an editor chose: text-left, align-right and similar classes from rich text keep their side.

Scripts that measure or move things use the direction too (getComputedStyle(document.documentElement).direction, or logical style properties such as marginInlineStart).

Content in another direction

A right-to-left text can appear on a left-to-right page and the other way round. The kernel's design/standard/templates/parts/exp_content_direction.tpl prints lang="..." dir="rtl" for a right-to-left content locale and nothing otherwise; use it on the element that holds the content (Content languages).

Names inside text

A name an editor typed, inserted into a translated sentence, must be isolated so its punctuation stays at its own end: dir="auto" on an inline element that holds only the name, <bdi> around a name inside a sentence or a block.

{'Written by %name'|i18n( 'design/mytheme',, hash( '%name', concat( '<bdi>', $author|wash, '</bdi>' ) ) )}

Testing

  • Sign in with a test account and choose a right-to-left interface language (Hebrew, Arabic), or add a right-to-left siteaccess for a public site.
  • Check the frame (columns swap), icons (only directional ones flip), forms, tables, paging and sliders.
  • Check a left-to-right page again: it must not have changed.
  • The admin's tests/tests/design/AdminRightToLeftTest.php reads the logical property names; copy its idea for your design.

Become an Exponential Partner

Partners share their information, provide funding, contribute back and develop the products with us, and that is how Exponential grows. A partner website and dashboard are planned for mid-2027: please become a partner today to speed up our growth rate and land new features faster.

Something wrong on this page? Report an error

Documentation license

This documentation is free documentation, licensed under the GNU Free Documentation License 1.3 or later.

Exponential Copyright © 1998-2026 Exponential Foundation and 7x