Loading...
Loading...
Right-to-left (RTL) layout and bidirectional text support for Hebrew, Arabic, Persian, and Urdu interfaces. Use when building UI that must support RTL languages, converting physical CSS/Tailwind properties to logical ones, handling mixed-direction (bidi) text, mirroring directional icons, or testing an app with dir="rtl".
npx skill4agent add mindrally/skills rtl-internationalizationmargin-left/rightpadding-left/rightleftrighttext-align: left/rightml-*mr-*pl-*pr-*left-*right-*margin-inline-startms-*dirdir="rtl"dir="auto"<html><bdi>Intldir="rtl"directionwriting-mode| Physical (avoid) | Logical (use) |
|---|---|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
/* Before: breaks in RTL */
.card {
margin-left: 1rem;
padding-right: 1.5rem;
border-left: 2px solid var(--border);
text-align: left;
}
/* After: direction-agnostic */
.card {
margin-inline-start: 1rem;
padding-inline-end: 1.5rem;
border-inline-start: 2px solid var(--border);
text-align: start;
}lrms-4ml-4me-4mr-4ps-4pl-4pe-4pr-4start-0left-0end-0right-0text-starttext-lefttext-endtext-right<!-- Before -->
<div class="ml-4 pr-6 text-left">...</div>
<!-- After -->
<div class="ms-4 pe-6 text-start">...</div>LeftRightpaddingStartpaddingEndpaddingLeftpaddingRightmarginStartmarginEndmarginLeftmarginRightborderStartWidthborderEndWidthborderLeftWidthborderRightWidthstartendleftrightconst styles = StyleSheet.create({
row: {
flexDirection: 'row',
paddingStart: 16,
paddingEnd: 16,
},
badge: {
position: 'absolute',
end: 8, // flips automatically with I18nManager.isRTL
top: 8,
},
})<bdi><p>User <bdi>{userName}</bdi> posted a comment</p>
<p>Order number: <bdi>{orderCode}</bdi> has shipped</p><bdi>/* Mirror an icon only when the document is RTL */
[dir="rtl"] .icon-chevron-forward {
transform: scaleX(-1);
}// React: pick the mirrored icon variant based on direction
function BackButton({ dir }: { dir: 'ltr' | 'rtl' }) {
const Icon = dir === 'rtl' ? ChevronRightIcon : ChevronLeftIcon
return (
<button aria-label="Back">
<Icon aria-hidden="true" />
</button>
)
}t()intl.formatMessage()Intl.NumberFormatIntl.DateTimeFormatdir="auto"dir="rtl"dir="ltr"const currency = new Intl.NumberFormat('ar-EG', {
style: 'currency',
currency: 'EGP',
}).format(1234.5)
// "١٬٢٣٤٫٥٠ ج.م."
document.documentElement.dir = locale.startsWith('ar') || locale.startsWith('he') ? 'rtl' : 'ltr'
document.documentElement.lang = localedir="rtl"dirml-*lefttext-align: leftname + ": " + valuedir="rtl"leftright