Chapter 02 Foundations
Right to left
Arabic is a first language here. Set lang and dir on the page; every component turns by itself.
Logical properties
The kit writes start and end, never left and right. So should you.
| Write | Instead of | Tailwind | For |
|---|---|---|---|
margin-inline-start | margin-left | ms-4 | Space before, on the reading side. |
padding-inline-end | padding-right | pe-4 | Space after. |
inset-inline-start | left | start-0 | Position from the start edge. |
border-inline-start | border-left | border-s-4 | A start bar, like the side bar current link. |
text-align: start | text-align: left | text-start | Text follows the reading side. |
scale: -1 1 on :dir(rtl) | two icons | rtl:-scale-x-100 | Mirror an arrow that points a way. |
Try the direction
The same markup; only lang and dir change.
Breadcrumbs, switch and a start border
Separators, the switch knob and the start border all turn round.
Paid by card
<html lang="en" dir="ltr">
<nav class="ui-breadcrumbs">…</nav>
<label class="ui-switch">…</label>
</html>What turns, what does not
Direction-free things keep their shape.
| Turns around | Stays as is | Why |
|---|---|---|
Text, padding, borders | Logos and code | Code is always left to right. |
Back and next arrows | Check, clock, play | They do not point a way. |
Switch knob, drawers | Numbers | 1042 reads left to right in both. |
Rules
- Never
ml-,pr-,left-: they stay put in Arabic. - Give a word in the other language its own
lang. - One kind of digit per product:
ar-EGwrites ١٠٤٢,ar-EG-u-nu-latnwrites 1042.