Utilities
Direction
Right-to-left provider. Every component and motion mirrors.
Examples and variants
RTL
The alert mirrors.
function DirectionRtl() {
return (
<DirectionProvider dir="rtl">
<Alert icon={<InfoIcon />} className="w-full max-w-xs">
<AlertTitle>كل الحركات تنعكس</AlertTitle>
</Alert>
</DirectionProvider>
)
}Spec drawing
Measured from the live component at default density. Each code maps to the token that sets it; change the token and the drawing follows.
Install
With the CLI
The shadcn CLI only delivers files: it copies our code from the Isotopi registry into your project and installs the packages it uses. Add the foundation once, then the component.
npx shadcn@latest add https://isotopi.com/r/minimal.json
npx shadcn@latest add https://isotopi.com/r/direction.jsonBy hand
No CLI needed. Add the foundation once (see Getting started), then follow these steps. They include every component this one builds on.
Install the packages it uses.
Terminalnpm install @base-ui/reactCopy this file to the same paths in your project. Imports use the
@/alias for your project root.components/ui/direction.tsxdirection
components/ui/direction.tsx"use client" import * as React from "react" import { DirectionProvider as DirectionPrimitive } from "@base-ui/react/direction-provider" /* Direction: tells components the reading direction. Every Isotopi motion uses logical sides (start/end), so pills, sheets and rolls mirror in RTL. */ function DirectionProvider({ dir = "ltr", children }: { dir?: "ltr" | "rtl"; children: React.ReactNode }) { return ( <DirectionPrimitive direction={dir}> <div dir={dir} data-slot="direction" className="contents"> {children} </div> </DirectionPrimitive> ) } export { DirectionProvider }
Imports
What the examples on this page import:
import { InfoIcon } from "lucide-react"
import { Alert, AlertTitle } from "@/components/ui/alert"
import { AspectRatio } from "@/components/ui/aspect-ratio"
import { Button } from "@/components/ui/button"
import { Collapsible, CollapsibleContent, CollapsibleLabel, CollapsibleTrigger } from "@/components/ui/collapsible"
import { DirectionProvider } from "@/components/ui/direction"
import { Kbd, KbdGroup } from "@/components/ui/kbd"
import { ScrollArea } from "@/components/ui/scroll-area"
import { Heading, Text } from "@/components/ui/typography"Anatomy
- 1Provider · Sets dir and Base UI's direction.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
dir | "ltr" | "rtl" | "ltr" | Reading direction. |
Tokens
Every visual spec is a component token in styles/tokens/components.css, pointing at a semantic token. Change a token to restyle the component; themes change the semantic layer.
This utility has no component tokens; it uses semantic tokens directly.
| Token | Points to | Light | Dark |
|---|
Motion
| Trigger | What happens | Tokens |
|---|---|---|
| — | Slides and stretches use logical sides. | — |
Calm keeps the motion without overshoot. Still (and reduced motion) keeps a designed frame with no movement.
Accessibility
- Set lang and dir on the page too.
Code
"use client"
import * as React from "react"
import { DirectionProvider as DirectionPrimitive } from "@base-ui/react/direction-provider"
/*
Direction: tells components the reading direction. Every Isotopi motion
uses logical sides (start/end), so pills, sheets and rolls mirror in RTL.
*/
function DirectionProvider({ dir = "ltr", children }: { dir?: "ltr" | "rtl"; children: React.ReactNode }) {
return (
<DirectionPrimitive direction={dir}>
<div dir={dir} data-slot="direction" className="contents">
{children}
</div>
</DirectionPrimitive>
)
}
export { DirectionProvider }