Direction provider
Sets the reading direction (ltr or rtl) once for every Radix-based component below it.
Source@monoline/react 0.4.0Markdown for AI toolsstable
- Built on radix-ui/Direction
- 2 parts, named exports
- Arrow keys follow the reading direction: in rtl, ArrowLeft moves to the next tab, slider step up or toolbar item.
- Pair it with a dir attribute on html so the stylesheet mirrors layout too.
Import
import '@monoline/css';
import {DirectionProvider} from '@monoline/react';
Not installed yet? Pick a route.
Copies the source and its styles into your project.
npx monoline add direction-provider
It needs radix-ui; install it if your project does not have it:
npm install radix-ui
Usage
import {DirectionProvider, Tabs, TabsContent, TabsList, TabsTrigger} from '@monoline/react';
<div dir="rtl">
<DirectionProvider dir="rtl">
<Tabs defaultValue="a">
<TabsList aria-label="Sections">
<TabsTrigger value="a">الأول</TabsTrigger>
<TabsTrigger value="b">الثاني</TabsTrigger>
</TabsList>
<TabsContent value="a">محتوى</TabsContent>
<TabsContent value="b">محتوى آخر</TabsContent>
</Tabs>
</DirectionProvider>
</div>
Anatomy
Import the parts you need and nest them like this.
import {DirectionProvider, useDirection} from '@monoline/react';
<DirectionProvider>
<useDirection />
</DirectionProvider>
Examples
Props
DirectionProviderProps
| Prop | Type | Default | Description |
|---|---|---|---|
dir required | "ltr" | "rtl" | – | Reading direction for everything below: `ltr` or `rtl`. |
children | ReactNode | – | The part of the app that should use this direction. |
Accessibility
- Arrow keys follow the reading direction: in rtl, ArrowLeft moves to the next tab, slider step up or toolbar item.
- Pair it with a dir attribute on html so the stylesheet mirrors layout too.
Keyboard
| Keys | Action |
|---|---|
| Arrow keys | Follow the reading direction: in rtl |
| ArrowLeft | Moves to the next tab, slider step up or toolbar item |