Skip to content

shadcn.io is not affiliated with official shadcn/ui

Shadcn Direction for React

Set left-to-right or right-to-left flow for a subtree.

StartltrEnd

Installation

bunx --bun shadcn@latest add https://kit.dev/r/radix/direction.json

Usage

import { DirectionProvider } from "@/components/ui/direction";
<DirectionProvider direction="ltr">
  <p>Content inherits the provided direction.</p>
</DirectionProvider>
import { useDirection } from "@/components/ui/direction";

const Example = () => {
  const direction = useDirection();
  return <div>Current direction: {direction}</div>;
};

See the RTL configuration guide for document-level direction. This page does not replace locale setup.

Demos

Rtl

Right-to-left direction. Logical ms / me spacing follows the reading direction.

API Reference

DirectionProvider

PropType
children?React.ReactNode

useDirection