Overview
Radix UI Primitives are built with internationalization in mind, providing automatic support for right-to-left (RTL) languages and direction-aware interactions.Components automatically adapt keyboard navigation, positioning, and animations based on the reading direction of your application.
Reading Direction (RTL/LTR)
Reading direction affects how users interact with components. Radix components adapt automatically.The Direction Provider
Wrap your application withDirectionProvider to set the reading direction:
packages/react/direction/src/direction.tsx:14:
Supported Values
"ltr"- Left-to-right (English, Spanish, French, etc.)"rtl"- Right-to-left (Arabic, Hebrew, Persian, etc.)
Using the Direction Hook
Components use theuseDirection hook internally to adapt behavior:
packages/react/direction/src/direction.tsx:21:
Direction-Aware Keyboard Navigation
Components automatically adjust keyboard navigation based on reading direction.Example: Accordion
Inpackages/react/accordion/src/accordion.tsx:230, the Accordion component adapts arrow key behavior:
What Gets Adapted
LTR (left-to-right):- Arrow Right → Move forward/next
- Arrow Left → Move backward/previous
- Arrow Right → Move backward/previous
- Arrow Left → Move forward/next
This happens automatically. You don’t need to write conditional logic for RTL support.
Per-Component Direction
You can override the global direction for individual components:Components Supporting dir Prop
These components accept a dir prop:
- Accordion
- ContextMenu
- DropdownMenu
- HoverCard
- Menubar
- NavigationMenu
- Popover
- Select
- Tooltip
Styling for RTL
Logical Properties
Use CSS logical properties for automatic RTL support:Direction Attribute Selectors
Use[dir] attribute in CSS:
Transforms and Animations
Flip transforms for RTL:Tailwind CSS
Tailwind supports RTL with thertl: modifier:
Complete RTL Example
Here’s a fully RTL-aware component:Locale Considerations
Text Alignment
Match text alignment to reading direction:Date and Number Formatting
UseIntl APIs for locale-aware formatting:
String Translation
Integrate with i18n libraries:HTML Direction Attribute
Always set thedir attribute on your HTML:
Setting
dir on the <html> element ensures the entire document respects the reading direction, including browser UI like scrollbars.Testing RTL Support
Manual Testing
- Add the DirectionProvider with
dir="rtl" - Verify visual layout mirrors correctly
- Test keyboard navigation (arrow keys)
- Check text alignment and spacing
- Test on actual RTL content (Arabic, Hebrew)
Automated Testing
Common RTL Pitfalls
1. Hardcoded Directional Styles
❌ Avoid:2. Missing dir Attribute
❌ Avoid:
3. Asymmetric Layouts
Be careful with custom layouts that assume LTR: ❌ Avoid:4. Icons and Images
Flip directional icons in RTL:Browser Support
RTL features are well-supported:- CSS logical properties: All modern browsers
dirattribute: All browsers- DirectionProvider: Works everywhere React works
Summary
Radix UI internationalization provides:- Automatic RTL support via DirectionProvider
- Direction-aware keyboard navigation
- Per-component direction overrides
- Works with any i18n library
- No extra configuration needed
Just wrap your app with
DirectionProvider and Radix components automatically adapt to the reading direction.Related Concepts
- Philosophy - Learn about the principles behind i18n support
- Customization - Style components for different locales
- State Management - Manage locale-aware state