examples/direction-rtl.tsx
"use client";import { Direction } from "@/components/wensity/direction";export function RTLDemo() {return (<Direction direction="rtl"><div><p>محتويات باللغة العربية</p><button>إرسال</button></div></Direction>);}
A React direction provider for RTL and LTR layouts that sets dir for Arabic, Hebrew, and Persian, informs Base UI, and exposes a useDirection hook.
Practical examples and common states for the same installable component.
Explicit right-to-left direction for RTL languages.
Auto-detects direction from a language tag.
LTR vs RTL comparison of the same component.
Direction is a React and Tailwind CSS direction provider, in Next.js or any React app, for right to left languages such as Arabic, Hebrew, Persian, and Urdu. It sets dir on a wrapper, or on your element with asChild, and passes it to Base UI so menus, sliders, and popovers flip correctly. Set direction to rtl or ltr directly, or turn on dynamic and pass a lang code to choose it from the language. useDirection reads the value anywhere below. dynamic only looks at the lang you pass, so read the locale from your router or the html element yourself.
Run the following command
pnpm dlx wensity@latest add direction
npx wensity@latest add direction
yarn dlx wensity@latest add direction
bunx wensity@latest add direction
Import Direction from @/components/wensity/direction and render it anywhere in your React or Next.js app. The source lands in your own repo, so every prop, class and animation below is yours to edit.
import { Direction, useDirection } from "@/components/wensity/direction";export function RTLExample() {return (<Direction direction="rtl"><p>This text and all children flow right-to-left.</p></Direction>);}export function DynamicExample() {return (<Direction dynamic lang="ar"><p>يتكيف هذا النص تلقائيًا مع اللغة العربية.</p></Direction>);}
| Prop | Type | Default | Description |
|---|---|---|---|
direction | "ltr" | "rtl" | - | Explicit text direction for the subtree. |
dynamic | boolean | false | Derives the direction from lang instead of setting it explicitly. |
lang | string | - | BCP 47 language tag used with dynamic, such as en, ar, or he. |
asChild | boolean | false | Merges onto the child element instead of wrapping it in a div. |
React typography components for headings 1 to 6, lead and muted text, and inline code, plus a Prose wrapper that styles markdown without a plugin.
A React navigation menu on Base UI for site headers, with hover dropdowns, mega menu panels, icons, descriptions, nested links, and a compact size.
A React app sidebar with collapsible, icon rail, floating, and resizable modes, grouped sections, badge counts, nested links, and a gliding active pill.
A React range slider on Base UI with one or two thumbs, a value bubble that shows while dragging, formatted values, and a minimum thumb gap.

SVG text riding a curved wave, arc, or circle path on a seamless, light loop.

A seamless, GPU-only logo strip that never stutters or snaps at the loop point.

A 3D tilted image grid with alternating rows scrolling infinitely in both directions.

A per-character slide-left cascade with a cleanly staggered entrance timing.