Separator
A separator is a thin rule that divides content, announced only when the division carries meaning.
Kyoto
Osaka
Nara
Installation
npx shadcn@latest add @flyingsalmon/separatorUsage
import { Separator } from '@/components/ui/separator'
export function PlaceList() {
return (
<div className="flex flex-col gap-3">
<p>Kyoto</p>
<Separator />
<p>Osaka</p>
</div>
)
}Examples
Vertical
Vertical stretches to the height of the flex or grid row it sits in, so a toolbar divider needs no explicit height.
Announced
Set decorative to false when the boundary carries meaning that no other markup states, such as between two form sections with no headings. It looks identical; only screen readers hear the difference.
Traveller details
Passport details
Spacing from the parent
The separator has no margin. The parent’s gap sets the rhythm of the rows and the rules between them: gap-2 around the first rule, gap-6 around the second.
Day 1 · Lisbon
Day 2 · Sintra
Day 3 · Cascais
Day 4 · Porto
Guidelines
When to use
- Between siblings that own no border of their own: rows in a list, groups in a toolbar, a panel's heading over its body.
When not to use
Do and don’t
- DoUse rules to divide one surface into blocks, such as the questions on one card.Whole surfaces already separate by their border and a background step. A rule is for the parts inside one surface, which share its edge.
- DoPut a rule only between items, never before the first or after the last.A rule divides two things. At either end it divides nothing and reads as a stray border.
- DoGive the rule equal space above and below.Centred, it belongs to neither neighbour, and the rows and the rules between them keep one rhythm.
- Don’tPlace a separator beside something that already draws a border.The boundary is already there, and a second line only doubles it.
- Don’tPut words in the rule, as in an “or” between a sign-in form and its other options.A rule divides and says nothing. Write the “or” as text of its own.
Accessibility
A separator is decorative by default and a screen reader hears nothing. With decorative={false} it exposes role="separator"; a vertical one also carries aria-orientation="vertical", and a horizontal one sets nothing because ARIA already defaults to horizontal. The separator is never focusable and never enters the tab order.
API
Separator
Also takes every <div> attribute except children, so a labelled rule is a different shape you build in the app that needs it. There is no colour prop and no size; pass a colour through className if you must. The separator has no margin: space it with the parent’s gap, so one number sets the rhythm for the rows and the rules between them.
| Prop | Type | Default | Description |
|---|---|---|---|
| orientation | SeparatorOrientation | SeparatorOrientation.Horizontal | Horizontal fills the width of its parent. Vertical stretches to the height of its flex or grid row; in a parent that is neither, pass a height through className. |
| decorative | boolean | true | When true the separator is hidden from assistive technology. Set false to announce it. |