Right-to-left

Set up matix/ui for Arabic, Hebrew, Persian, and other right-to-left languages.

Set the direction in two places

The dir attribute mirrors the layout. matix styles use logical properties, such as paddingInlineStart, so they follow it. Base UI does not read the attribute. It reads the direction from DirectionProvider, so set both:

// app/layout.tsx
import { DirectionProvider } from '@matix/components/direction-provider';

export default function RootLayout({ children }: { children: React.ReactNode }) {
  return (
    <html lang="ar" dir="rtl">
      <body>
        <DirectionProvider direction="rtl">{children}</DirectionProvider>
      </body>
    </html>
  );
}

If you leave out the provider, the layout mirrors, but these parts act as LTR:

  • Arrow keys move the wrong way in Tabs, RadioGroup, Menu, NavigationMenu, and Accordion.
  • The Slider moves opposite to the pointer and the arrow keys.
  • Popups placed on the inline-start or inline-end side open on the wrong side.

Example

These components sit in a dir="rtl" subtree with a provider. Try the arrow keys on the tabs and the calendar.

November 2026
Su
Mo
Tu
We
Th
Fr
Sa

What stays physical

  • Drawer side and Toast position name a screen edge. Pick the edge for your layout.
  • Code and Code.Block render dir="ltr", because code reads left to right. Pass dir to change it.

One subtree in another direction

Put dir on the subtree and wrap it in its own DirectionProvider. Overlays render in a portal in <body>, so they take the page direction. To keep an overlay in the subtree direction, pass container to its Portal.