Skip to content
Ballpoint

Direction

Tells every component inside which way text runs, so menus, sliders and tabs move the right way round in right-to-left languages.

From shadcn/ui
Built on Base UI Direction Provider

The slider fills from the start of the line, and the arrow keys follow the way it runs.

Installation

pnpm dlx shadcn@latest add @ballpoint/direction

Usage

tsx
import { DirectionProvider } from "@/components/ui/direction"

<html dir="rtl">
  <body>
    <DirectionProvider direction="rtl">{children}</DirectionProvider>
  </body>
</html>

API reference

direction (or dir)
default "ltr"
"ltr" | "rtl"

Which way text runs. Set `dir` on the page too: the provider only tells the components.

useDirection()
() => { direction }

Read it from any component inside.

Every other prop goes to Base UI's Direction Provider.