125k

Direction

アプリケーションのテキスト方向を設定するプロバイダー コンポーネント。

DirectionProvider コンポーネントは、アプリケーションのテキスト方向 (ltr または rtl) を設定するために使用されます。これは、アラビア語、ヘブライ語、ペルシア語などの右から左に記述する言語をサポートするために不可欠です。

RTL モードでのコンポーネントのプレビューを次に示します。言語を切り替えるには、言語セレクターを使用します。さらに例を参照するには、コンポーネント ページの RTL セクションを探してください。

تسجيل الدخول إلى حسابك
أدخل بريدك الإلكتروني أدناه لتسجيل الدخول إلى حسابك

インストール

pnpm dlx shadcn@latest add direction

使い方

import { DirectionProvider } from "@/components/ui/direction"
<html dir="rtl">
  <body>
    <DirectionProvider direction="rtl">
      {/* Your app content */}
    </DirectionProvider>
  </body>
</html>

useDirection

useDirection フックは、アプリケーションの現在の方向を取得するために使用されます。

import { useDirection } from "@/components/ui/direction"
 
function MyComponent() {
  const direction = useDirection()
  return <div>Current direction: {direction}</div>
}