Right-to-left (RTL)
Arabic, Hebrew, Persian, Urdu: set the page's direction and Momo mirrors itself. Layouts, menus, drawers, arrows, switches, step lines and the split view all follow.
Turn it on
Set the language and the direction on the page. That is all.
<html lang="ar" dir="rtl">Momo is written with "start" and "end" instead of "left" and "right", so nothing else changes. Code samples keep reading left to right.
See it
This box is right-to-left; the rest of the page is not. The same markup as everywhere else in these docs, with dir="rtl" on the wrapper.
- المجموع الفرعي
- $118.00
- الشحن
- $11.00
- الإجمالي
- $129.00
يُشحن خلال يوم عمل واحد إلى لشبونة.
فاتورة واحدة، مدفوعة بالكامل.
- السلة
- العنوان
- الدفع
- تم
سنرسل الطلب إلى العنوان الجديد.
<div dir="rtl" lang="ar" id="rtl-demo" class="stack" style="--stack-gap: 1.25rem">
<nav class="breadcrumb" aria-label="مسار التنقل">
<ol>
<li><a href="#see-it"><i class="mi mi-house"></i> الرئيسية</a></li>
<li><a href="#see-it">الطلبات</a></li>
<li aria-current="page">طلب <bdi>#10421</bdi></li>
</ol>
</nav>
<div class="tabs tabs-line" data-momo-tabs aria-label="الطلب" id="rtl-tabs">
<button class="tab" aria-controls="rtl-p1" aria-selected="true">التفاصيل</button>
<button class="tab" aria-controls="rtl-p2">الشحن</button>
<button class="tab" aria-controls="rtl-p3">الفواتير</button>
</div>
<div class="tab-panel" id="rtl-p1">
<div class="card">
<div class="card-body">
<div class="media media-center mb-4">
<span class="avatar bg-pink">آك</span>
<div class="media-body"><div class="media-title">آنا كيم</div><span class="media-meta">قبل ساعتين</span></div>
<div class="media-actions"><span class="badge badge-green-soft">مدفوع</span><a class="btn btn-sm" href="#see-it">عرض <i class="mi mi-arrow-right rtl-flip"></i></a></div>
</div>
<dl class="dl dl-between">
<dt>المجموع الفرعي</dt><dd><bdi>$118.00</bdi></dd>
<dt>الشحن</dt><dd><bdi>$11.00</bdi></dd>
<dt class="dl-total">الإجمالي</dt><dd><bdi>$129.00</bdi></dd>
</dl>
</div>
</div>
</div>
<div class="tab-panel" id="rtl-p2" hidden><p class="mb-0">يُشحن خلال يوم عمل واحد إلى لشبونة.</p></div>
<div class="tab-panel" id="rtl-p3" hidden><p class="mb-0">فاتورة واحدة، مدفوعة بالكامل.</p></div>
<ol class="steps" id="rtl-steps">
<li class="step is-done"><span class="step-marker"></span><span class="step-label">السلة</span></li>
<li class="step is-done"><span class="step-marker"></span><span class="step-label">العنوان</span></li>
<li class="step" aria-current="step"><span class="step-marker"></span><span class="step-label">الدفع</span></li>
<li class="step"><span class="step-marker"></span><span class="step-label">تم</span></li>
</ol>
<div class="cluster" style="--stack-gap: 1.5rem">
<label class="switch" id="rtl-switch"><input type="checkbox" role="switch" checked> إشعارات البريد</label>
<label class="switch"><input type="checkbox" role="switch"> الوضع الداكن</label>
<input class="slider w-48" type="range" min="0" max="100" value="30" aria-label="مستوى الصوت" id="rtl-slider">
</div>
<div class="form-icon" style="max-width: 22rem"><i class="mi mi-search" aria-hidden="true"></i><input class="form-control" type="search" placeholder="ابحث في الطلبات" aria-label="ابحث في الطلبات"></div>
<div class="alert" role="status">
<span class="alert-icon"><i class="mi mi-info"></i></span>
<div class="alert-body"><b class="alert-title">تم تحديث العنوان</b><p>سنرسل الطلب إلى العنوان الجديد.</p></div>
<button class="btn btn-icon btn-sm btn-ghost" type="button" data-momo-dismiss aria-label="إغلاق"><i class="mi mi-x"></i></button>
</div>
<nav aria-label="الصفحات">
<ul class="pager" id="rtl-pager">
<li><a href="#see-it" rel="prev" aria-label="الصفحة السابقة"><i class="mi mi-chevron-left rtl-flip" aria-hidden="true"></i></a></li>
<li><a href="#see-it">1</a></li>
<li><a href="#see-it" aria-current="page">2</a></li>
<li><a href="#see-it">3</a></li>
<li><a href="#see-it" rel="next" aria-label="الصفحة التالية"><i class="mi mi-chevron-right rtl-flip" aria-hidden="true"></i></a></li>
</ul>
</nav>
</div>Look at what changed by itself: the breadcrumb and the tabs start on the right, the avatar sits at the start of its row and the buttons at the end, the step line runs right to left, the switch knob and the slider start on the right, the search icon and the close button swapped sides, and the pager arrows point the other way. Press the arrow keys on the tabs: Left now moves forward.
Icons that point
Momo flips its own arrows (breadcrumbs, menus, the split view's back button, tree and list chevrons). For an arrow icon of your own, add .rtl-flip and it mirrors in right-to-left only. Icons that do not point anywhere (a house, a bell, a check) need nothing.
<div dir="rtl" lang="ar" class="cluster">
<a class="btn" href="#icons-that-point" id="rtl-flip-yes">التالي <i class="mi mi-arrow-right rtl-flip"></i></a>
<span class="text-sm text-muted" dir="ltr">with .rtl-flip</span>
<a class="btn" href="#icons-that-point" id="rtl-flip-no">التالي <i class="mi mi-arrow-right"></i></a>
<span class="text-sm text-muted" dir="ltr">without (points the wrong way)</span>
</div><a class="btn" href="/next">التالي <i class="mi mi-arrow-right rtl-flip"></i></a>In your own CSS and classes
Use the "start" and "end" names and your additions mirror too.
| Use | Instead of |
|---|---|
ms-*, me-*, ps-*, pe-* | left and right margins and padding |
text-start, text-end | text-left, text-right |
start-0, end-0, border-s, border-e, rounded-s, rounded-e, float-start | left-0, right-0 and the like |
margin-inline-start, padding-inline-end, inset-inline-start, border-inline-end | margin-left, padding-right, left, border-right in your CSS |
.rtl-flip | mirroring a pointing icon by hand |
Mixed text
- Wrap order numbers, prices, phone numbers and names in another script in
<bdi>, so their punctuation stays in place:<bdi>#10421</bdi>. - For text people typed (a comment, a search field), use
dir="auto": each one follows its own first letter. - One right-to-left section in a left-to-right page works too: put
dir="rtl"on its wrapper, as in the demo above. Menus, dialogs and toasts are drawn at the top of the page, so they follow the page's direction, not the section's.
Good to know
- The hard shadow keeps falling to the bottom right in both directions. It is a light source, not a reading direction.
- Charts, videos, clocks and code keep running left to right, as they do in right-to-left apps.
- Momo's font has no Arabic or Hebrew letters, so the browser picks a system font for them. To choose one, put it first in
--momo-font. - Every page of these docs loads right-to-left with no sideways scroll, on a laptop and on a phone. That is checked by a test.