Shadcn
Direction 文本方向
为组件树提供 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.
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.
Preview
每日推荐
根据你的收听偏好生成
30 首歌曲 · 今天更新
Scopify 说明
本页按 shadcn/ui 官方 Radix UI 组件文档的章节与示例完整整理。示例预览使用 Scopify 当前的 @scopify/ui/shadcn 实现;导入路径、主题 Token 和行为差异以本仓库源码为准。
Installation
npx shadcn@latest add directionUsage
import { DirectionProvider } from "@scopify/ui/shadcn/components/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 "@scopify/ui/shadcn/components/direction"
function MyComponent() {
const direction = useDirection()
return <div>Current direction: {direction}</div>
}