组件
DirectionProvider 组件用于设置应用的文本方向(ltr 或 rtl)。这对于支持像阿拉伯语、希伯来语和波斯语这样的从右向左的语言是必不可少的。
🌐 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.
以下是组件在从右到左模式下的预览。使用语言选择器切换语言。要查看更多示例,请在组件页面上查找 RTL 部分。
🌐 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
用法
🌐 Usage
import { DirectionProvider } from "@/components/ui/direction"<html dir="rtl">
<body>
<DirectionProvider direction="rtl">
</DirectionProvider>
</body>
</html>useDirection
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>
}