Stable in React
Direction Provider
Enables right-to-left behavior for the Base UI components inside it.
Direction Provider renders nothing to look at; its usage is in the code.
Install#
One package per framework. Direction Provider's parts come from it; the anatomy tab at the top shows how they nest.
bun add @▢▢▢▢/reactOne part. The example uses one of them; the data does not say which are required.
DirectionProviderEnables RTL behavior for Base UI components.
Examples#
The demo at the top is the one example this component has so far.
Styling and accessibility#
The parts ship no styles. Style their states with these attributes; the CSS tab at the top has a sheet. The same CSS works in all five frameworks.
Direction Provider has no data attributes or CSS variables.
Keyboard
DirectionProvider adds no keys; it flips the arrow keys of the components inside, so ArrowLeft moves forward in a right-to-left slider or toolbar.
Set for you
no attribute; setthe browser lays out and reads text right to left, and the components move the same wayDirectionProviderdir="rtl"on an element yourself
API reference#
2 props across 1 parts, in React syntax, and className, style, render once for every part. Open a row to try it.
DirectionProvider · all partsUse it in React#
What differs from the React API. Switch the framework at the top of the page.
@▢▢▢▢/react is the React 19 package. Its parts, props, data attributes and error messages are upstream Base UI's, and upstream's own tests run against it.
- Parts
Each component is its own entry point and exports one namespace named after it.
import { Switch } from '@base-ui-next/react/switch' export function Example() { return ( <Switch.Root> <Switch.Thumb /> </Switch.Root> ) }A part renders the element its API reference names, such as a
<span>forSwitch.Root. - Props and events
Props and callbacks have upstream's names and signatures:
onCheckedChange(checked, details),onOpenChange(open, details),onValueChange(value, details).detailscarriesreason,event,cancel()andallowPropagation(). Native handlers are React's (onClick,onKeyDown), andevent.preventBaseUIHandler()stops a part's own handler. - Styling
classNametakes a string or a function(state) => string;styletakes an object or a function(state) => object. The state'sdata-*attributes are on the element for CSS. renderrendertakes an element (render={<a href="/docs" />}) or a function(props, state) => elementthat spreadspropson what it returns.- Refs
refreaches the part's element. Imperative handles are ref props, as upstream:inputRef, andactionsRef({ validate }on Field and Form,{ unmount, close }on Dialog). - Binding
A part is controlled when its value prop (
checked,open,value) is set, and uncontrolled with thedefaultform (defaultChecked,defaultOpen,defaultValue). React has no two-way binding: pair the value with its change callback. - From @base-ui/reactChange the import from
@base-ui/react/<component>to@▢▢▢▢/react/<component>. - From @base-ui/reactNothing else changes: props, parts, data attributes and errors are the same.