Skip to content

Tailwind logical properties for RTL

Map physical Tailwind classes to logical utilities and migrate spacing, insets, borders and alignment while preserving the English layout.

By , Founder of Ritla

Guide14 min read

Replacing ml-4 with ms-4 is a useful edit only when that margin means “space before this element in reading order.” It is the wrong edit when the margin aligns a marker with a fixed coordinate on a map. Both classes can look identical in English, which is why an automated replacement can pass the English screenshot and still encode the wrong relationship.

Tailwind logical properties let a single component express starting and ending edges without maintaining separate English and Arabic styles. The migration work is deciding which relationships should follow direction, removing the physical rules they replace, and checking the resulting CSS at every relevant state.

This guide maps the utilities and follows a municipal tree-inspection dashboard through that process. It assumes the Arabic document already declares dir="rtl"; if it does not, fix document direction first. The focus here is migrating class lists, not installing Tailwind or translating the dashboard.

Read start and end as relationships, not synonyms#

For horizontal English text, inline start is left and inline end is right. For horizontal Arabic text, inline start is right and inline end is left. ms-4 expresses a starting margin; it does not contain an instruction to select Arabic or detect the language.

Direction and writing mode determine the mapping. MDN's margin-inline-start reference describes how the logical property relates to physical edges. An English note inside an Arabic report can establish its own direction, and its logical spacing then follows that local boundary.

Write down the intended relationship before editing a component: indentation from the report's start, a button at the toolbar's end, or a marker measured from the map's physical left edge. The first two are candidates for logical properties. The third is an intentional physical coordinate.

These mappings assume ordinary horizontal writing. Vertical writing introduces a different inline axis, so inline size is not always width and inline start is not always a horizontal edge. You do not need to redesign a horizontal Arabic dashboard for vertical writing, but you should avoid teaching the team that “start” universally means “right.”

Also distinguish the utility families. text-start aligns text, while flex alignment utilities operate along layout axes. A class name containing “start” is not sufficient evidence that it is interchangeable with a left-edge utility. Inspect the CSS property that Tailwind actually generates.

Map margins, padding, insets and alignment#

The table below starts from the existing English layout. Each replacement preserves its physical side in horizontal LTR and adapts that relationship in RTL.

Existing classLogical classGenerated relationship
ml-4ms-4margin-inline-start
mr-4me-4margin-inline-end
-ml-px-ms-pxNegative starting margin
ml-automs-autoAutomatic starting margin
mr-autome-autoAutomatic ending margin
pl-6ps-6padding-inline-start
pr-6pe-6padding-inline-end
left-4inset-s-4inset-inline-start
right-4inset-e-4inset-inline-end
text-lefttext-startAlign to the text element's start
text-righttext-endAlign to the text element's end

Tailwind documents margins, padding, insets and text alignment independently. Keep the property's meaning attached to the class rather than memorizing a visual swap.

The inset names above follow the current v4 documentation. The established v3.3/v3.4 names are start-4 and end-4. Check the installed version before changing spelling across a repository. A class shown in newer documentation is not proof that an older compiler generates it.

Preserve the value and modifiers when changing the relationship. A negative margin remains negative. An arbitrary padding value can remain arbitrary, as in pl-[18px] becoming ps-[18px]. A responsive declaration such as md:pr-6 becomes md:pe-6 when it has the same ending-edge meaning.

Do not convert a right edge to start simply because the Arabic version should place something on the right. If the original English component uses right-4 for a trailing attachment, its logical equivalent is end. Choosing start would also move the English attachment.

Automatic margins need available space and the intended layout axis. A logical auto margin is not a cure for an overfull toolbar. Likewise, replacing text-left cannot move the text element's box within its parent. Treat spacing, alignment and placement as separate relationships during review.

R022 covers explicit left alignment on majority-Arabic text. A finding should lead you to the element carrying that alignment, including inherited component styles and responsive utilities, rather than an unrelated direction attribute.

Migrate borders and corners as one component#

Borders can mark the starting or ending edge of a report section. Corner radii can identify the outside edges of a joined control. Both relationships need the same directional vocabulary.

Existing English classLogical classRTL physical counterpart
border-l-2border-s-2Right border
border-r-2border-e-2Left border
rounded-l-lgrounded-s-lgRight pair of corners
rounded-r-lgrounded-e-lgLeft pair of corners
rounded-tl-lgrounded-ss-lgTop-right corner
rounded-tr-lgrounded-se-lgTop-left corner
rounded-bl-lgrounded-es-lgBottom-right corner
rounded-br-lgrounded-ee-lgBottom-left corner

For a single logical corner, the first letter after rounded- identifies the block edge and the second identifies the inline edge. Under horizontal writing, rounded-es-lg therefore means bottom at inline start. Tailwind's radius reference shows the mapping, and its border-width reference covers logical border sides.

Consider the tree dashboard's joined report-mode buttons. Their DOM order should remain stable; only the outside corners and shared seam need to follow direction.

Problem

html
<div class="inline-flex">  <button type="button" class="rounded-l-lg border px-4 py-2">    تقرير الأشجار  </button>  <button type="button" class="-ml-px rounded-r-lg border px-4 py-2">    صور المعاينة  </button></div>

The physical corners stay attached to the English sides. The negative left margin also remains on the left, even when the second button follows the first toward the other side of the row.

Better

html
<div class="inline-flex">  <button type="button" class="rounded-s-lg border px-4 py-2">    تقرير الأشجار  </button>  <button type="button" class="-ms-px rounded-e-lg border px-4 py-2">    صور المعاينة  </button></div>

Under LTR, the logical classes map to the same sides as the original. Under RTL, the outside corners follow the group's start and end, and the negative margin follows the second button's starting side. Check the shared seam and both outside edges in the browser. Keep focus outlines visible while reviewing the join; clipping the group to hide a border defect can introduce a different usability problem.

Do not change only the corner classes and leave the physical overlap. A component is the unit of migration, not an isolated matching token. Compare the English control before and after, then verify Arabic with the actual translated labels.

Rewrite asymmetric spacing as a complete pair#

An inspection-summary box may use symmetric padding as a base, then reserve more room on its English right side:

html
<div class="px-4 pr-10">ملاحظات فريق المعاينة</div>

If that larger space belongs at the reading end, express the resulting pair directly:

html
<div class="ps-4 pe-10">ملاحظات فريق المعاينة</div>

The intended English values remain the same: the smaller starting inset and larger ending inset. In Arabic, those roles exchange physical sides. Review the original computed values before approving the replacement, especially if the component has additional theme or responsive rules.

This is a useful case for reasoning from the final relationship rather than replacing one matching token. Leaving the physical pr-10 in place makes the reserved space stay on the right. Adding another ending declaration without understanding the base shorthand leaves more declarations to reconcile in the cascade.

Check whether the reserved space is still needed. If it exists for an absolutely positioned attachment, migrate that attachment's anchor and the reserved padding together. If it exists for a physical feature in a diagram, keep the diagram relationship explicit instead of mirroring the padding independently.

A genuinely symmetric px-4 needs no extra start/end classes just for horizontal RTL. Use a pair when the component has two different roles to express, rather than expanding every symmetric utility into a longer class list.

Remove physical rules instead of layering replacements#

A logical utility does not automatically override every physical instruction related to the same element. Sometimes the declarations compete for one side; in the other direction they can affect two different sides.

This explicit CSS example makes the distinction visible:

css
.inspection-note {  padding-inline-start: 1.25rem;  padding-left: 0;}

With horizontal LTR direction, the declarations map to the same physical padding, so the later left declaration wins. With horizontal RTL direction, the starting padding maps to the right, while the left reset remains on the left. The CSS Logical Properties specification explains how corresponding physical and logical declarations participate in the cascade.

An inherited component default or a reset utility can create this situation during a Tailwind migration. A class list containing pl-0 and ps-5 deserves inspection even if it looks correct in one direction. Reordering the strings in the HTML attribute does not determine the stylesheet's declaration order.

Inspect the final class list and the winning rules, including layers, specificity and important declarations. Tailwind's utility-composition guidance explains conflicts between utilities. A class-merging helper is another implementation layer, not proof that every logical/physical conflict was resolved as intended.

Remove obsolete direction overrides too. A component previously expressed as ml-4 rtl:ml-0 rtl:mr-4 may reduce to ms-4 when its intent is a starting margin. Review the complete set, not just the unprefixed class, or an old reset can survive the migration.

Check locally LTR descendants before collapsing such branches. An ancestor-based direction selector and an element's own logical direction are not necessarily equivalent in nested content. Preserve the intended behavior, rather than assuming a shorter class list must reproduce every old selector's effect.

Keep positioning direction separate from content direction#

The element that owns a logical property matters. Changing a child to LTR can also change how that child's logical inset maps, even though the surrounding Arabic panel remains RTL.

Suppose an English inspection note should sit at the report panel's inline end. This implementation places the inset and the English direction on the same box:

html
<div class="relative min-h-24">  <div dir="ltr" lang="en" class="absolute inset-e-4 top-4">    Inspection notes  </div></div>

The positioned element is LTR, so its inline end maps to the right in horizontal writing. An RTL parent does not change that child's own mapping. MDN's inset-inline-end reference describes the direction and writing-mode inputs.

Move the content direction onto an inner element while letting the positioning wrapper inherit the panel's direction:

html
<div class="relative min-h-24">  <div class="absolute inset-e-4 top-4">    <div dir="ltr" lang="en">Inspection notes</div>  </div></div>

The wrapper now owns the report-relative placement, while the inner box owns English text direction. In LTR, the wrapper still anchors at the right. In RTL, it anchors at the left while keeping the note's text LTR.

Test with the panel inheriting each document direction. Inspect the wrapper and inner box separately in computed styles. The useful fix is the separation of responsibilities, not adding more rtl: utilities to force the note into place.

The same distinction applies to spacing around embedded LTR content. If the space belongs to the surrounding Arabic component, put it on an appropriately directed wrapper. If it belongs to the English content itself, a logical property on that content may be appropriate. Inline bidi isolation is another boundary; see nested LTR content when that requires more than layout changes.

Include scroll offsets and less obvious logical utilities#

The inspection dashboard may have a horizontal evidence strip with a control covering part of its starting edge. Ordinary padding and scrolling alignment offsets are different tools.

scroll-ps-6 sets starting scroll padding on the scroller; scroll-pe-6 sets its ending counterpart. They inset the scrollport region used to align scroll targets, leaving room for controls that cover an edge. MDN explains scroll-padding-inline-start, and Tailwind documents its scroll-padding utilities.

On an individual target, scroll-ms-6 and scroll-me-6 set logical scroll margins. Their physical English equivalents are scroll-ml-6 and scroll-mr-6. The scroll-margin reference covers that separate property family.

Test the actual alignment operation, including the first and last evidence items. Do not infer the resulting scroll position from the class name alone: available scroll range, snapping and the invoked scrolling operation also matter. Avoid adding both scroller padding and target margins for the same clearance without checking their combined effect.

For legacy floated content, current Tailwind also provides float-start/float-end and clear-start/clear-end. Check the float and clear references and the application's browser support before replacing their physical equivalents. Migrating a float's side does not by itself change the surrounding layout to flex or grid.

Logical sizing is available too, including inline-* utilities in the current sizing reference. That is a writing-mode decision, not a requirement to replace every w-* class on a horizontal Arabic page. Width remains width when only horizontal reading direction changes.

Find migration candidates without treating matches as defects#

Search the actual component sources, including class maps and shared wrappers. This command produces a review list for common physical utilities:

rg -n -g '*.{html,jsx,tsx,vue,svelte,js,ts}' '(ml-|mr-|pl-|pr-|left-|right-|text-left|text-right|rounded-(l|r|tl|tr|bl|br)-|border-(l|r)(-|[^a-z]))' src

Adjust src to the project's source directories. The search is intentionally a candidate finder, not a parser or a complete RTL audit. It can match comments, string data or intentional physical coordinates. It also will not explain arbitrary CSS, computed styles from dependencies or every valid utility spelling.

Group matches by component and property family. For the report-mode control, migrate corners and overlap together. For a positioned inspection panel, inspect the anchor, its width constraints and any transforms before deciding which classes should change.

Search CSS and style objects for physical declarations separately. A clean Tailwind class list does not remove marginLeft from a component's inline styles or left from a library placement calculation. Include pseudo-elements and arbitrary property utilities such as [padding-left:18px] in that review.

Classify each candidate as reading-relative, intentionally physical or dependent on a behavior that needs investigation. Do not automatically convert uncertain map coordinates and image overlays. Put the reason for an intentional physical edge near its implementation when the surrounding component otherwise uses logical properties.

Avoid an unrestricted string replacement across the repository. It can alter identifiers and fixtures, leave companion resets behind, or convert classes whose physical side was meaningful. A migration script should understand complete class tokens and preserve the original file's syntax. Keep its output reviewable in component-sized changes.

Give a migration script a narrow contract. It can propose a class-token mapping after a component has been classified as reading-relative. It cannot infer whether a map coordinate or diagram annotation should move, and it should leave uncertain expressions for review rather than silently producing a plausible class name.

Token boundaries need care. Variant prefixes, arbitrary values and arbitrary variants can contain punctuation that also appears in CSS declarations. Splitting every string on a colon can misread a colon inside brackets. Similarly, matching right as a substring can touch a name that is not a utility at all. Use syntax-aware handling for the source language and preserve complete Tailwind tokens through the transformation.

Review generated output for deletions as well as replacements. The desired change may remove old RTL resets or two conditional classes, not merely substitute one prefix. When a class map is shared by several components, inspect every consumer before simplifying it. A direction-independent map marker and a reading-relative toolbar can use the same old physical utility for different reasons.

Start with a dry-run report containing the file, complete original token, proposed token and component relationship. Reject uncertain candidates there. After applying an accepted group, compile it and review its LTR and RTL states before widening the script's scope. A small automated edit with explicit assumptions is easier to trust than a large replacement whose correctness depends on a repository-wide convention that was never checked.

Preserve modifiers, values and build visibility#

Responsive and state variants are part of the original behavior. When an ending padding remains an ending padding, md:hover:pr-6 becomes md:hover:pe-6; the breakpoint, interaction state and value should remain intact.

Do not add rtl: to the logical replacement by default. A plain ps-6 already adapts to direction. Making it RTL-only changes which styles exist in English and may leave the old physical class responsible for that mode.

Inspect compound class-building code before editing it. A complete logical class such as ms-6 should appear as a literal token, or as a complete string in a controlled class map. Tailwind's source-detection guide explains why arbitrary string interpolation is not interpreted as runtime class construction by the compiler.

Compile representative classes using the installed theme. A numeric suffix is a design-system value, not a universal pixel count. Keep custom spacing tokens and CSS variables unchanged unless the migration deliberately includes a spacing redesign.

Verify shared-package source registration as well. A logical class introduced only inside a component package needs to be visible to the consuming build. A development page that happens to use the same class elsewhere can conceal a missing source boundary.

After building, inspect both the literal class and its generated declaration. This distinguishes an unavailable utility from a generated utility that loses in the cascade. Do not begin adding important modifiers until you know which of those failures you have.

Leave non-logical behavior out of the replacement map#

There is no general logical equivalent for every directional-looking class. A translation along the x-axis is still a physical translation. A drawn arrow does not reverse because its containing box uses logical padding. A background position can identify an image feature that must stay fixed.

Treat those as separate design decisions after migrating the relevant edges. Use explicit direction-dependent rules when the behavior should change, and retain the physical instruction when it should not. Do not claim that converting margins made a map overlay, a scrolling algorithm or an animation direction-correct.

The same applies to flex order. Changing spacing does not require reversing the source array or adding row-reverse. Keep DOM sequence aligned with the intended reading and interaction sequence, then test keyboard navigation where the component is interactive.

Symmetric properties also need judgment. A uniformly rounded report card does not need separate starting and ending radius utilities. A centered panel is not made more RTL-capable by replacing one symmetric utility with several directional declarations. Keep the implementation that states the relationship clearly.

R030 covers direction-sensitive physical properties without an RTL override. It does not establish that an intentional physical position is wrong. R031 covers left/right floats on content elements in RTL context without an override; changing a different property nearby does not address that specific finding.

Verify computed edges and the preserved English layout#

For each migrated component, compare the English version before and after at the same width, theme and state. Then inspect Arabic at that width. A successful migration preserves the English relationships while adapting the intended edges in Arabic.

Use computed styles to see where a logical property resolved. Add id="inspection-second-action" to the second report-mode button, then run:

js
const element = document.querySelector('#inspection-second-action');if (!element) throw new Error('Open the inspection control first.');const style = getComputedStyle(element);console.table({  direction: style.direction,  writingMode: style.writingMode,  marginInlineStart: style.marginInlineStart,  marginLeft: style.marginLeft,  marginRight: style.marginRight,  topLeftRadius: style.borderTopLeftRadius,  topRightRadius: style.borderTopRightRadius,});

MDN documents getComputedStyle and the resolved values it returns. Combine those values with the matched-rule view and a screenshot. A correct negative starting margin alone does not prove that the join, corner shape and focus outline are usable.

Repeat with the relevant responsive utilities active, and include disabled, selected, focused and expanded states where they alter styling. Test nested LTR content independently. Use the production stylesheet so the test also exercises source detection and utility generation.

Keep a direct mapping test alongside the visual review when a conflict is difficult to diagnose. For example, a fixture with ps-[18px] and no competing padding declarations should resolve the starting padding to the left in horizontal LTR and to the right in horizontal RTL. Inspect both physical sides so an unchanged leftover padding does not pass unnoticed. Then put the same utility back into the real component: if the isolated mapping passes but the component differs, investigate the cascade or direction boundary rather than changing the mapping table.

Keep a short migration record for exceptions: which edge should follow reading direction, which coordinate remains physical, and which screenshot or interaction verifies each. That makes the next refactor less likely to reintroduce a physical reset that only looked harmless in English.

A free Ritla scan can surface direction-sensitive physical properties without RTL overrides after the migration; confirm each repair against the original English component as well. Continue with converting LTR CSS to RTL for non-Tailwind declarations, or debugging RTL layout problems when a generated logical utility still resolves to the wrong relationship.

Checks in this guide

See what your Arabic pages are hiding

Paste a URL. Ritla renders the page on desktop and mobile, runs every check, and shows the top issues with screenshot evidence.

Scan a page freeBrowse the checks