Components
- Accordion
- Alert
- Alert Dialog
- Aspect Ratio
- Attachment
- Avatar
- Badge
- Breadcrumb
- Bubble
- Button
- Button Group
- Calendar
- Card
- Carousel
- Chart
- Checkbox
- Code Block
- Collapsible
- Combobox
- Command
- Context Menu
- Data Table
- Date Picker
- Dialog
- Direction
- Drawer
- Dropdown Menu
- Empty
- Field
- Hover Card
- Input
- Input Group
- Input OTP
- Item
- Kbd
- Label
- Marker
- Message
- Message Scroller
- Native Select
- Pagination
- Popover
- Progress
- Questionnaire
- Radio Group
- Resizable
- Scroll Area
- Select
- Separator
- Sheet
- Sidebar
- Skeleton
- Slider
- Sonner
- Spinner
- Switch
- Table
- Tabs
- Textarea
- Toast
- Toggle
- Toggle Group
- Tooltip
- Trace
- Typography
AI Elements
Get Started
@shadcn/react
@shadcn/helpers
Utilities
The DirectionProvider component is used to set the text direction (ltr or rtl) for your application. This is essential for supporting right-to-left languages like Arabic, Hebrew, and Persian.
Here's a preview of the component in RTL mode. Use the language selector to switch the language. To see more examples, look for the RTL section on components pages.
تسجيل الدخول إلى حسابك
أدخل بريدك الإلكتروني أدناه لتسجيل الدخول إلى حسابك
Installation#
pnpm dlx shadcn@latest add direction
Install the following dependencies:
pnpm add react-aria-components
Copy and paste the following code into your project.
"use client"
import * as React from "react"
import { I18nProvider, useLocale } from "react-aria-components"
function DirectionProvider(
props: React.ComponentProps<typeof I18nProvider> & {
direction?: "ltr" | "rtl"
}
) {
// For compatibility with Radix / Base UI, if only a `direction` is provided and not a `locale`,
// create a locale string that forces the direction by setting the script to arabic or latin.
const { locale: currentLocale } = useLocale()
let locale = props.locale
if (!locale && props.direction) {
locale = new Intl.Locale(currentLocale, {
script: props.direction === "rtl" ? "Arab" : "Latn",
}).toString()
}
return <I18nProvider {...props} locale={locale} />
}
function useDirection() {
const { direction } = useLocale()
return direction
}
export { DirectionProvider, I18nProvider, useDirection, useLocale }
Update the import paths to match your project setup.
Usage#
import { DirectionProvider } from "@/components/ui/direction"<html dir="rtl">
<body>
<DirectionProvider direction="rtl">
{/* Your app content */}
</DirectionProvider>
</body>
</html>useDirection#
The useDirection hook is used to get the current direction of the application.
import { useDirection } from "@/components/ui/direction"
function MyComponent() {
const direction = useDirection()
return <div>Current direction: {direction}</div>
}Deploy your shadcn/ui app on Vercel
Trusted by OpenAI, Sonos, Adobe, and more.
Vercel provides tools and infrastructure to deploy apps and features at scale.
Deploy to Vercel