Skip to content
satin

Right-to-left

Satin in Arabic, Hebrew or Persian: dir on the html element and Radix's DirectionProvider.

A settings screen in Arabic, right to left. Switch Direction to LTR to compare. Every component follows the direction; the lists under the setup say what mirrors and the few things that stay left to right.

    Set the direction on html

    Put dir="rtl" and the language on <html>, not on a wrapper. The browser then lays out every row from the right and aligns text to it, and menus, dialogs and toasts, which render at the end of <body>, inherit the direction too. A wrapper div would leave them left to right.

    index.html
    <html lang="ar" dir="rtl">

    Tell Radix with DirectionProvider

    Satin's interactive parts are built on Radix, which reads the direction from React context rather than the DOM. Without the provider, the layout is right to left but the arrow keys in Tabs, menus, Segmented control and Slider still move the LTR way. radix-ui comes with @uisatin/ui; with pnpm or another strict package manager, add it to your own dependencies before importing it.

    SatinLabels translates the words components say on their own, such as Close, Previous and Next, so the screen doesn't fall back to English.

    providers.tsx
    // The root of your app
    import { Direction } from 'radix-ui'
    import { SatinLabels } from '@uisatin/ui/labels'
    
    export function Providers({ children }: { children: React.ReactNode }) {
      return (
        <Direction.Provider dir="rtl">
          <SatinLabels labels={{ close: 'إغلاق', previous: 'السابق', next: 'التالي' }}>{children}</SatinLabels>
        </Direction.Provider>
      )
    }

    What mirrors

    Spacing, corners and alignment use start and end throughout, so they mirror with no extra setup. Beyond that:

    • Button, Button group, Split button, Input groupIcons and label swap sides; joined parts line up from the right, round on the outside and square where they meet.
    • Input, Select, Combobox, Date pickerValues and placeholders start at the right; leading and trailing icons and text (https://, USD) sit on their own side of the value.
    • TextareaThe resize grip is in the bottom-left corner, where the browser puts the resizer.
    • Checkbox, Radio, SwitchThe control sits before the label, on the right; a Switch that's on has its thumb on the left.
    • Tabs, Segmented controlOrder, the sliding indicator, and Left/Right arrow keys.
    • Breadcrumb, Pagination, Context menu, Sidebar, Decision card, Date pickerArrows point the right-to-left way, and Pagination rolls the next page in from the left.
    • Link, Attachment, Announcement bar, Action button, Agent suggestionForward arrows point left, and the arrow for a link that opens elsewhere points up and to the left.
    • Date pickerLeft moves to the next day and Right to the one before; Page Up, Page Down, Home and End work as before. The range band runs leftwards.
    • Dialog, Sheet, Popover, Card, Alert, Banner, Announcement barThe close button is in the top-left corner; footer buttons end on the left, primary last.
    • ToastThe stack sits in the bottom-left corner and swipes away to the left.
    • TableThe first column sticks on the right; the row hover outline, columns with align "right", the scroll fade and the scroll bar all mirror.
    • Form, Field groupIn the horizontal layout the labels are in the right column.
    • Menus, Accordion, Chip, Message, Attachment, Tooltip, Prompt bar, Citations, File upload, ListPaddings and indents mirror; the user's message bubble has its tail on the left.
    • Progress, Skeleton, Streaming textThe indeterminate bar and Skeleton's shimmer run right to left; the caret follows the last letter.

    What stays left to right

    A few things keep their left-to-right shape in a right-to-left page: on purpose, or until Radix is told the direction.

    • Code blockCode reads left to right in any page; its header (file name, Copy) follows the page.
    • Input OTPA code reads left to right, digit by digit.
    • Line, Area and Bar chartTime runs left to right, with the scale on the left, as is usual for charts in right-to-left interfaces. Channel and Donut charts follow the page.
    • SheetIts side is physical: side="right" stays on the right. For a sheet at the end of a right-to-left page, use side="left".
    • Slider, icon-only SidebarRadix takes the direction from DirectionProvider: without it a Slider fills from the left, and the Sidebar's tooltips open to the right (they still flip at the screen's edge).