# Direction

> Sets native writing direction and an optional language for a group of localized content.

- Kind: ui · Category: Layout and media · Interactivity: native
- Install: `npx shadcn@latest add @haze/direction`
- File: `src/components/haze/ui/direction.astro`
- npm dependencies: none
- Registry dependencies: @haze/utils
- Docs page: https://hazeui.com/ui/direction

## Use when
- A localized view needs right-to-left layout.
- One part of a page has a different writing direction from its surroundings.

## Avoid when
- The entire page uses one direction and can set it on the HTML element.

## Alternatives
- [separator](https://hazeui.com/ui/separator.md)
- [scroll-area](https://hazeui.com/ui/scroll-area.md)

## Props

| Name | Type | Default | Required | Description |
|---|---|---|---|---|
| dir | `"ltr" \| "rtl" \| "auto"` | auto | no | Writing direction for the content. |
| lang | `string` |  | no | Optional BCP 47 language tag. |
| class | `string` |  | no | Classes for the content wrapper. |

## Accessibility
- The native lang attribute allows assistive technology to choose the appropriate pronunciation.
- Use logical spacing and alignment in slotted content.

## Agent prompts

### Install and use

Install the Haze UI component "Direction" with `npx shadcn@latest add @haze/direction`. If components.json has no "@haze" registry yet, add "registries": { "@haze": "https://hazeui.com/r/{name}.json" }. If src/styles/haze.css does not exist yet, run `npx shadcn@latest add @haze/theme` once and import it from the global stylesheet after Tailwind. The CLI stops at an overwrite question when a Haze file already exists and differs, even with --yes, and then installs nothing after it: read its output. If the user has not edited their Haze files, re-run with --overwrite to take the registry versions; if they have, ask them before overwriting. Then import Direction from "@/components/haze/ui/direction.astro" (or the relative path) and render it where it fits the page. Keep Haze token classes (bg-background, text-muted-foreground, border-border...) and never hardcode colors. Docs: https://hazeui.com/ui/direction.md

### Customize with real content

Adapt the Haze direction ui for our product. Replace the demo values of these props with our real content: dir, lang, class. Keep the layout, the heading level rules and these accessibility details: The native lang attribute allows assistive technology to choose the appropriate pronunciation. Use logical spacing and alignment in slotted content. Do not add raw color classes; use the Haze tokens.

### Choose the right block

Before using direction, check it fits: use it when a localized view needs right-to-left layout.; one part of a page has a different writing direction from its surroundings.. Avoid it when the entire page uses one direction and can set it on the html element.. Alternatives: @haze/separator, @haze/scroll-area.

## Example requests that should lead here
- Use right-to-left layout for Arabic messages.
- Set Hebrew as the language of a small translated summary.

## Source

```astro
---
import { cn } from "../../../lib/haze/utils";

interface Props {
  dir?: "ltr" | "rtl" | "auto";
  lang?: string;
  class?: string;
}

const { dir = "auto", lang, class: className } = Astro.props;
---

<div dir={dir} lang={lang} class={cn("min-w-0 text-start", className)}>
  <slot />
</div>
```
