Direction

A provider component that sets the text direction for your application.

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.

Installation

npx shadcn@latest add @rescript-shadcn/Direction

Usage

<Direction.DirectionProvider>
  {"Direction context"->React.string}
</Direction.DirectionProvider>

Direction.use

The Direction.use hook is used to get the current direction of the application.

module MyComponent = {
  @react.component 
  let make = () => {
    let direction = Direction.use()
 
    <div> {`Current direction: ${(direction :> string)}`->React.string} </div>
  }
}