---
title: "Direction"
description: "Sets the reading direction for the parts inside it. In right to left, arrow keys swap and menus open on the correct side."
url: https://gelatinui.com/components/direction
markdown_url: https://gelatinui.com/components/direction.md
access: free
install: "npx shadcn@latest add @gelatin-ui/direction"
registry_item: https://gelatinui.com/r/direction.json
version: "2026-11-08"
index: https://gelatinui.com/llms.txt
docs_index: https://gelatinui.com/docs/llms.txt
---

# Direction

> Sets the reading direction for the parts inside it. In right to left, arrow keys swap and menus open on the correct side.

Page: https://gelatinui.com/components/direction

## When to use it

Best for: Right-to-left pages: the arrow keys, submenu sides, and popup sides of every part.

- Wrap the app in `DirectionProvider direction="rtl"` and set `dir="rtl"` on `<html>`.
- Use `useDirection()` in your own component when its behavior depends on the direction.

## When not to use it

- To flip only the layout, set `dir` alone: the components use logical classes.

## Notes for agents

- `dir` flips the layout; `DirectionProvider` flips the keys and popup sides. Set both.
- It renders no element and sets no style.
- React Aria fields read the direction from `I18nProvider locale`, not from this provider.

## Usage

Wrap the app, and set `dir` on the same element or on `<html>`.

```tsx title="app-root.tsx"
import type { ReactNode } from "react";

import { DirectionProvider } from "@/components/ui/direction";

export function AppRoot({ children }: { children: ReactNode }) {
  return (
    <div dir="rtl">
      <DirectionProvider direction="rtl">{children}</DirectionProvider>
    </div>
  );
}
```

## Compose

Rules:

- Group with a Frame (`group-in-frames`): Put related panels in one `Frame` with its header and footer outside the panels, and keep a plain `Card` for one block of content.
- Compose the parts (`compose-parts`): Build each item from its named parts as children, and pass your text and icons in as parts.
- Every state is designed (`every-state`): Give each view of data its loading, empty, and error states: a skeleton in the final layout, an `Empty` with an illustration and one next action, and an error that says what failed and how to retry.

## Add it

```bash
npx shadcn@latest add @gelatin-ui/direction
```

It adds 1 registry items: 1 files, 15 lines, and the npm packages `@base-ui/react`.

## For AI agents

- Every item, one file: https://gelatinui.com/llms.txt
- MCP server (`search_items`, `get_item`, `get_install_plan`): https://gelatinui.com/mcp

## Related

- [Tabs](https://gelatinui.com/components/tabs.md)
- [Menu](https://gelatinui.com/components/menu.md)
- [Slider](https://gelatinui.com/components/slider.md)

## Accessibility

In right to left, the arrow keys follow the reading order: ArrowLeft moves to the next tab.
