Skip to content

Latest commit

 

History

History
30 lines (20 loc) · 801 Bytes

File metadata and controls

30 lines (20 loc) · 801 Bytes

DirectionProvider

Declares the writing direction (ltr / rtl) for all Radix-based components rendered underneath. Wraps @radix-ui/react-direction.

Import

import { DirectionProvider, useDirection } from '@bgunnarsson/react-primitives'

Usage

<DirectionProvider dir="rtl">
  <App />
</DirectionProvider>

useDirection

Reads the current direction inside a component rendered beneath a DirectionProvider. Returns 'ltr' by default when no provider is present.

const direction = useDirection()

Notes

  • Radix primitives (DropdownMenu, Slider, Select, etc.) consult this provider to flip keyboard navigation and positioning correctly.
  • Set dir="rtl" on the HTML <html> element as well so native layout and CSS logical properties respond.