Loading...
Apex includes built-in RTL (Right-to-Left) support for internationalization. Perfect for Arabic, Hebrew, and other RTL languages.
Apex uses logical properties that automatically adapt to the document direction. When you set dir="rtl" on your HTML element, all utilities with directional properties will flip automatically.
See how layout utilities automatically flip in RTL mode.
This content flows right-to-left
<div dir="rtl" class="flex items-center gap-4 p-4 bg-gray-50 rounded-lg">
<div class="w-16 h-16 bg-blue-500 rounded flex items-center justify-center text-white font-bold">
A
</div>
<div class="flex-1">
<h3 class="font-semibold text-gray-900">RTL Content</h3>
<p class="text-gray-600 text-sm">This content flows right-to-left</p>
</div>
<button class="px-4 py-2 bg-blue-500 text-white rounded">
Button
</button>
</div>Margin and padding utilities automatically adapt to text direction.
<!-- LTR: margin-left: 1rem -->
<!-- RTL: margin-right: 1rem -->
<div dir="rtl">
<div class="ml-4">Margin Start (logical)</div>
<div class="mr-4">Margin End (logical)</div>
</div>
<!-- Physical properties stay fixed -->
<div class="border-l-4 border-blue-500 pl-4">
Physical left border
</div>Flexbox layouts maintain their visual structure in RTL mode.
<div dir="rtl" class="flex justify-between items-center gap-4">
<div class="bg-blue-500 text-white px-4 py-2 rounded">
Start (visual right in RTL)
</div>
<div class="bg-green-500 text-white px-4 py-2 rounded">
Center
</div>
<div class="bg-purple-500 text-white px-4 py-2 rounded">
End (visual left in RTL)
</div>
</div>Text alignment utilities work with logical properties.
text-left (in RTL = right)
text-right (in RTL = left)
text-start (logical)
text-end (logical)
<div dir="rtl">
<p class="text-left">Text left (becomes right in RTL)</p>
<p class="text-right">Text right (becomes left in RTL)</p>
<p class="text-start">Text start (logical)</p>
<p class="text-end">Text end (logical)</p>
</div><!-- In your HTML head -->
<html lang="ar" dir="rtl">
<!-- Or set dynamically with JavaScript -->
<script>
document.documentElement.dir = 'rtl';
document.documentElement.lang = 'ar';
</script>// middleware.ts
import createMiddleware from 'next-intl/middleware';
export default createMiddleware({
locales: ['en', 'ar', 'he'],
defaultLocale: 'en'
});
// Automatically handles RTL for Arabic and Hebrew
// The dir attribute is set based on localeArabic
ar
Hebrew
he
Persian
fa
Urdu
ur