Separator
Hairline divider, horizontal or vertical, with an optional centered micro-label such as "or" between two sections.
pnpm dlx shadcn@latest add @haze/separator---
import { cn } from "../../../lib/haze/utils";
interface Props {
orientation?: "horizontal" | "vertical";
/** True hides the line from assistive tech. False exposes role="separator"; a label then becomes its accessible name. */
decorative?: boolean;
/** Short text centered on a horizontal line; ignored when vertical. */
label?: string;
class?: string;
}
const { orientation = "horizontal", decorative = true, label, class: className } = Astro.props;
const vertical = orientation === "vertical";
const role = decorative ? "none" : "separator";
const ariaOrientation = !decorative && vertical ? "vertical" : undefined;
const labelled = Boolean(label) && !vertical;
// A real separator has no readable children, so the label names it instead of being read as loose text.
const ariaLabel = !decorative && labelled ? label : undefined;
---
{
labelled ? (
<div role={role} aria-label={ariaLabel} class={cn("flex w-full items-center gap-3", className)}>
<span class="h-px flex-1 bg-border" aria-hidden="true" />
<span
aria-hidden={decorative ? undefined : "true"}
class="text-xs/4 font-medium text-muted-foreground"
>{label}</span>
<span class="h-px flex-1 bg-border" aria-hidden="true" />
</div>
) : (
<div
role={role}
aria-orientation={ariaOrientation}
class={cn("shrink-0 bg-border", vertical ? "w-px self-stretch" : "h-px w-full", className)}
/>
)
}When to use
- Splitting a form into groups, for example social sign-in above an email form with an "or" label
- Dividing inline items in a toolbar or footer link row with a vertical rule
- Marking a thematic break between settings sections inside one card
When not to use
- Spacing alone already groups the content; extra lines add visual noise
Installation
Add the Haze registry to components.json once, then install Separator with the shadcn CLI. Works in any Astro project with Tailwind CSS v4.
pnpm dlx shadcn@latest add @haze/separatornpx shadcn@latest add @haze/separatoryarn dlx shadcn@latest add @haze/separatorbunx --bun shadcn@latest add @haze/separatorFirst time? Registry and theme setup
1. Add to components.json:
{
"registries": {
"@haze": "http://localhost:4329/r/{name}.json"
}
}2. Install the theme once: npx shadcn@latest add @haze/theme, then import it after Tailwind in your global CSS:@import "./haze.css";
API reference
| Prop | Type | Default | Description |
|---|---|---|---|
| orientation | "horizontal" | "vertical" | "horizontal" | Direction of the line; vertical stretches to the height of a flex parent. |
| decorative | boolean | true | When true the line is hidden from assistive tech (role="none"). When false it is a real separator (role="separator", plus aria-orientation when vertical) and a label becomes its accessible name. |
| label | string | – | Short text centered on a horizontal line, drawn as an uppercase micro-label; ignored when vertical. |
| class | string | – | Extra classes, for example margins. |
Accessibility
- Decorative by default (role="none"), so screen readers skip pure styling lines.
- With decorative set to false it exposes role="separator" and adds aria-orientation only for the vertical case.
- A real separator that has a label is named by it (aria-label) and the visible label text is hidden from the tree, so the text is read once as the name and not as loose content.
- A label on a decorative separator stays plain text in the reading order, so keep it short and meaningful, not a symbol.
Notes for AI
Copy into Claude Code, Cursor, Codex or any coding agent. Agents can also read the Markdown version of this page.
Install and use
Install the Haze UI component "Separator" with `npx shadcn@latest add @haze/separator`. If components.json has no "@haze" registry yet, add "registries": { "@haze": "http://localhost:4329/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 Separator from "@/components/haze/ui/separator.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: http://localhost:4329/ui/separator.md
Customize with real content
Adapt the Haze separator ui for our product. Replace the demo values of these props with our real content: orientation, decorative, label, class. Keep the layout, the heading level rules and these accessibility details: Decorative by default (role="none"), so screen readers skip pure styling lines. With decorative set to false it exposes role="separator" and adds aria-orientation only for the vertical case. A real separator that has a label is named by it (aria-label) and the visible label text is hidden from the tree, so the text is read once as the name and not as loose content. A label on a decorative separator stays plain text in the reading order, so keep it short and meaningful, not a symbol. Do not add raw color classes; use the Haze tokens.
Choose the right block
Before using separator, check it fits: use it when splitting a form into groups, for example social sign-in above an email form with an "or" label; dividing inline items in a toolbar or footer link row with a vertical rule; marking a thematic break between settings sections inside one card. Avoid it when spacing alone already groups the content; extra lines add visual noise.
Dependencies
- @haze/utils
- @haze/theme (one-time setup)
Source · Original Haze UI work.