Utilities
Direction
Transparent Base UI DirectionProvider re-export for RTL context — pair with document dir.
Base UI
How it works
DirectionProvider and useDirection are a transparent re-export of Base UI’s direction utilities. They feed Base UI context so wrapped controls flip for RTL; they do not set HTML dir or CSS direction. Pair the provider with dir="rtl" on a portal ancestor — usually <html> — so body-mounted popups inherit the same direction.
Optional beyond Setup. Import from @viraui/react instead of @base-ui/react/direction-provider. Full API stays on Base UI.
Common examples
RTL subtree with Slider
import { DirectionProvider, Slider } from '@viraui/react';
<div dir="rtl">
<DirectionProvider direction="rtl">
<Slider defaultValue={25} aria-label="Volume" />
</DirectionProvider>
</div>Read direction in a portal-safe hook
import { DirectionProvider, Text, useDirection } from '@viraui/react';
function DirectionLabel() {
const direction = useDirection();
return <Text size="s">Direction: {direction}</Text>;
}
<DirectionProvider direction="rtl">
<DirectionLabel />
</DirectionProvider>Ask your agent
This app needs right-to-left layout. Put direction context on the app shell so Base UI–backed controls flip correctly, and set document direction so portaled overlays match. Keep the wiring minimal — use the ViraUI re-export, not a direct Base UI import.Last updated on