PatternAvailable
Direction
Direction context for right-to-left component behavior.
Installation
Add the component and its dependencies from the registry running on your computer.
terminal
npx shadcn@latest add https://brutallab.facilito.dev/r/direction.jsonUsage
Import the component into your project and keep the source code under your control.
tsx
'use client';
import { DirectionProvider } from '@/components/ui/direction';
import { Button } from '@/components/ui/button';
export default function Demo() {
return (
<DirectionProvider direction="rtl">
<div
dir="rtl"
className="flex gap-3 rounded-lg border-2 border-ink bg-card p-5"
>
<Button variant="outline">الأول</Button>
<Button>التالي</Button>
</div>
</DirectionProvider>
);
}
States & interaction
Appearance, behavior and keyboard checks.
- The composition inherits its controls’ states. Test empty, content, loading and error cases where the application needs them.
- Examples on this page are runnable; the displayed code uses the same components. Business logic belongs to the consumer.
- Test the example with Tab and Shift+Tab. Focus must stay visible in both themes.
API Reference
BrutalLab-specific properties. Native attributes are supported as well.
| Prop | Type | Default | Description |
|---|---|---|---|
| direction | ltr / rtl | ltr | Text and interaction direction. |
Accessibility
Rules that should remain intact when adapting the component to a product.
Set both the direction context and the document or container dir attribute. Localize labels too.
Retain keyboard focus styles and test the composition with keyboard navigation.
Use className for visual customization; preserve the primitive ARIA attributes.