Direction
A direction provider for left-to-right and right-to-left interface contexts.
Playground
RTL context
Controls inherit reading direction.
RTL context
Controls inherit reading direction.
Installation
Install in any React + Tailwind project:
$npx shadcn@latest add https://twigs.globirdenergy.com.au/r/direction.json
Source
The exact source file used by this page, preferring the Twigs registry file when one exists and falling back to the current shadcn-generated primitive.
"use client"
import * as React from "react"
import { Direction } from "radix-ui"
function DirectionProvider({
dir,
direction,
children,
}: React.ComponentProps<typeof Direction.DirectionProvider> & {
direction?: React.ComponentProps<typeof Direction.DirectionProvider>["dir"]
}) {
return (
<Direction.DirectionProvider dir={direction ?? dir}>
{children}
</Direction.DirectionProvider>
)
}
const useDirection = Direction.useDirection
export { DirectionProvider, useDirection }