Direction
Sets left-to-right or right-to-left for the Base UI parts inside.
"use client"
import { DirectionProvider } from "@/components/ui/direction"
import { Slider } from "@/components/ui/slider"
import { Switch } from "@/components/ui/switch"
// Right-to-left layout for Arabic or Hebrew: Base UI parts follow it.
export default function DirectionDemo() {
return (
<DirectionProvider direction="rtl">
<div dir="rtl" className="flex w-64 flex-col gap-4 text-mac-body">
<label className="flex items-center justify-between">
الواي فاي
<Switch size="sm" defaultChecked />
</label>
<Slider defaultValue={[30]} aria-label="السطوع" />
</div>
</DirectionProvider>
)
}Installation
pnpm dlx shadcn@latest add @cupertinoui/directionThe first install also adds the macOS theme. See Installation to set up the registry.
Usage
import { DirectionProvider } from "@/components/ui/direction"
<DirectionProvider direction="rtl">…</DirectionProvider>API Reference
Every part forwards the props of the underlying Base UI Direction Provider part. The props below are the ones CupertinoUI adds or changes.
DirectionProvider
| Prop | Type | Description |
|---|---|---|
direction | "ltr" | "rtl"Default: "ltr" | The reading direction. |
className | string | Extra classes, merged with the component's own. |