# Separator

A line between two pieces of content (WAI-ARIA `separator`). It has no state, no action and nothing pending: what it adds over a bare `<hr>` is the vertical case (`aria-orientation` plus a styling hook), the decorative case (`role="none"`) and a name for your styled layer. It has no `"use client"`, so a Server Component renders it.

## Anatomy

```tsx
import { Separator } from "@funstack/ui/separator";

<article>…</article>
<Separator />                                     {/* hr role="separator" aria-orientation="horizontal" */}
<article>…</article>

<nav aria-label="Breadcrumb">
  <a href="/">Home</a>
  <Separator orientation="vertical" decorative /> {/* hr role="none" data-orientation="vertical" data-decorative */}
  <a href="/docs">Docs</a>
</nav>
```

One plain component, no parts. It renders `<hr>`, which is void: there is no `children` prop. The part writes the role itself (`separator`, or `none` while `decorative`), so a `render` element of another tag is a separator too.

```tsx title="SeparatorLayout.tsx"
// No "use client": a Server Component, and Separator runs on the server with it (the part is
// directive-free). A semantic separator between two sections of an article, and decorative
// vertical lines between the links of a breadcrumb, where "separator" would only be noise.
import { Separator } from "@funstack/ui/separator";

export function SeparatorLayout() {
  return (
    <div className="demo-separator-card">
      <nav aria-label="Breadcrumb" className="demo-separator-crumbs">
        <a href="/">Docs</a>
        <Separator orientation="vertical" decorative className="demo-separator" />
        <a href="/getting-started">Getting started</a>
        <Separator orientation="vertical" decorative className="demo-separator" />
        <span aria-current="page">Separator</span>
      </nav>
      <section>
        <h4>Release notes</h4>
        <p>Separator is a plain line with a name, an orientation and a decorative mode.</p>
      </section>
      {/* Semantic: a thematic break that a screen reader announces. */}
      <Separator className={(s) => `demo-separator demo-separator-${s.orientation}`} />
      <section>
        <h4>Comments</h4>
        <p>No comments yet.</p>
      </section>
    </div>
  );
}
```

```css title="separator.css"
/* Separator: an <hr> keeps its user-agent margins, border and border-derived height, so the
   recipe resets them and draws the line from data-orientation. */
.demo-separator {
  margin: 0;
  border: 0;
  background: var(--color-border);
  flex: none;
}
.demo-separator[data-orientation="horizontal"] {
  block-size: 1px;
  inline-size: 100%;
}
.demo-separator[data-orientation="vertical"] {
  inline-size: 1px;
  align-self: stretch;
}

.demo-separator-card {
  display: grid;
  gap: 0.75rem;
  inline-size: min(28rem, 100%);
}
.demo-separator-card h4 {
  margin: 0 0 0.25rem;
}
.demo-separator-card p {
  margin: 0;
  color: var(--color-text-secondary);
}

.demo-separator-crumbs {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.9rem;
}
.demo-separator-crumbs .demo-separator {
  block-size: 1em;
  align-self: center;
  transform: rotate(20deg);
}
```

This example is a Server Component (no `"use client"`), and so is `Separator`: the function `className` ran on the server.

## Props

| Prop | Type | Default | Description |
| - | - | - | - |
| `orientation` | `"horizontal" \| "vertical"` | `"horizontal"` | The direction of the line itself. A vertical separator sits between things laid out in a row. Rendered as `aria-orientation` (both values) and `data-orientation`. |
| `decorative` | `boolean` | `false` | A visual line with no meaning: `role="none"` and no `aria-orientation`. Leave it `false` when the line marks a real break a sighted reader would describe ("the comments start here"); set it for a line that only tidies a row or a list. |
| `className` | `string \| ((state: SeparatorState) => string \| undefined)` | – | A class name, or a function of the part's state. |
| `style` | `CSSProperties \| ((state: SeparatorState) => CSSProperties \| undefined)` | – | Inline style, or a function of the part's state. |
| `render` | `ReactElement \| ((props, state: SeparatorState) => ReactNode)` | – | Replace the `<hr>` (element form) or take over rendering (function form). The part writes the role, so any element is a separator (or, with `decorative`, none). |

- **State**: `SeparatorState` is `{ orientation, decorative }`, the two props (`orientation` defaults to `"horizontal"`).
- **Owned**: `role` in both modes (`"separator"`, or `"none"` while `decorative`; either wins over a `render` element's own), `aria-orientation`, `data-orientation`, `data-decorative`.

Every other `<hr>` prop passes through, `ref` included. `role="separator"` on the default `<hr>` restates its implicit role: assistive technology reads the same thing, and `render={<div />}` stays a separator.

## Data attributes

| Attribute | On | Meaning |
| - | - | - |
| `data-orientation` | Separator | `"horizontal"` or `"vertical"`, always (decorative too). |
| `aria-orientation` | Separator | The same value; absent while `decorative`. |
| `data-decorative` | Separator | Present while `decorative` (`state.decorative`). |

## Keyboard and ARIA

| Case | Rendered | Announced |
| - | - | - |
| default | `hr[role=separator][aria-orientation=horizontal]` | separator |
| `orientation="vertical"` | `hr[role=separator][aria-orientation=vertical]` | separator, vertical where the screen reader says so |
| `decorative` | `hr[role=none][data-decorative]` | nothing |

- Not focusable, no keyboard interaction, in every case.
- Inside a [Menu](menu.md), a [Toolbar](toolbar.md) or a [Select](select.md), use `Menu.Separator`, `Toolbar.Separator` (it takes the orientation perpendicular to the toolbar's) or `Select.Separator`.
- Inside a listbox ([Combobox](combobox.md), [MultiSelect](multi-select.md)) a `separator` is not allowed, but a `role="none"` element is: `<Separator decorative />` between options or groups is valid, a semantic one is not.
- A line with a word in it ("or") is `render={<div>or</div>}`. The children of a separator are presentational, so the word is not announced: right for "or", wrong for anything that matters.

## Transition types

Concept: [Transitions & ViewTransition](../concepts/transitions.md#transition-types)

None: the separator never changes on its own, and it takes no `transition` prop.

## Optimistic and pending

Concept: [Pending & optimistic state](../concepts/pending-and-optimistic.md)

None: no state, no action, nothing pending.

## Suspense

Concept: [Suspense](../concepts/suspense.md)

Nothing specific: the separator renders no content region.

## Browser-owned state

Concept: [Browser-owned state](../concepts/browser-owned-state.md)

None.

## Before hydration

Concept: [Server Components](../concepts/server-components.md#before-hydration)

Everything: there is no behaviour. The component is itself a Server Component; rendered by one, it runs once, on the server, function `className`, `style` and `render` included.

## Recipes

### CSS

The library ships no CSS. An `<hr>` has user-agent margins, a border and a border-derived height, so reset them:

```css
.separator { margin: 0; border: 0; background: var(--line); flex: none; }
.separator[data-orientation="horizontal"] { block-size: 1px; inline-size: 100%; }
.separator[data-orientation="vertical"]   { inline-size: 1px; align-self: stretch; }
```

Tailwind: `data-[orientation=horizontal]:h-px data-[orientation=vertical]:w-px`.

### Inside a Toolbar

A standalone `Separator` does not read the Toolbar's orientation (that would make it a client component). It works there, but stays horizontal unless told otherwise; use `Toolbar.Separator`.
