Skip to main content

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 with DirectionProvider to set the reading direction:
From 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 the useDirection hook internally to adapt behavior:
From packages/react/direction/src/direction.tsx:21:
The hook respects component-level dir props over global context, and defaults to "ltr" if neither is provided.

Direction-Aware Keyboard Navigation

Components automatically adjust keyboard navigation based on reading direction.

Example: Accordion

In packages/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
RTL (right-to-left):
  • 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
Check component documentation for specifics.

Styling for RTL

Logical Properties

Use CSS logical properties for automatic RTL support:
Logical property mappings:

Direction Attribute Selectors

Use [dir] attribute in CSS:

Transforms and Animations

Flip transforms for RTL:

Tailwind CSS

Tailwind supports RTL with the rtl: modifier:
Or enable RTL mode globally:

Complete RTL Example

Here’s a fully RTL-aware component:
With RTL-aware CSS:

Locale Considerations

Text Alignment

Match text alignment to reading direction:

Date and Number Formatting

Use Intl APIs for locale-aware formatting:

String Translation

Integrate with i18n libraries:

HTML Direction Attribute

Always set the dir attribute on your HTML:
Or in your HTML template:
Setting dir on the <html> element ensures the entire document respects the reading direction, including browser UI like scrollbars.

Testing RTL Support

Manual Testing

  1. Add the DirectionProvider with dir="rtl"
  2. Verify visual layout mirrors correctly
  3. Test keyboard navigation (arrow keys)
  4. Check text alignment and spacing
  5. Test on actual RTL content (Arabic, Hebrew)

Automated Testing


Common RTL Pitfalls

1. Hardcoded Directional Styles

Avoid:
Use:

2. Missing dir Attribute

Avoid:
Include:

3. Asymmetric Layouts

Be careful with custom layouts that assume LTR: Avoid:
Use:

4. Icons and Images

Flip directional icons in RTL:

Browser Support

RTL features are well-supported:
  • CSS logical properties: All modern browsers
  • dir attribute: All browsers
  • DirectionProvider: Works everywhere React works
For older browsers, consider adding a PostCSS plugin to transform logical properties to physical ones with [dir] selectors.

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.