ComponentsDisplay
Separator
A thin horizontal or vertical rule that separates content, with an optional inline label ("or", a date) placed at the start, center or end, and a dashed style. Built on React Aria's Separator, so it's announced correctly.
Desyne
Accessible React components with shadcn tokens.
Installation
pnpm dlx shadcn@latest add @desyne/separatorThe CLI installs dependencies and any other components this one uses.
Usage
import { Separator } from "@/components/ui/separator";<Separator />
<Separator orientation="vertical" />
<Separator label="or" />When to use
- Separator: to divide groups of content that belong to the same surface, such as sections of a form, groups in a toolbar or items in a breadcrumb-like row.
- Spacing alone is often enough. Reach for a separator when whitespace doesn't make the grouping clear.
- Card: when the groups need their own surface.
CardHeaderhas its ownseparatorprop. - Inside menus, use
MenuSeparator; between list rows, useItemSeparator.
Anatomy
A separator is a single element. The labelled version draws the two lines with ::before and ::after.
<Separator /> {/* <hr> */}
<Separator orientation="vertical" /> {/* <div role="separator"> */}
<Separator label="or" /> {/* line · label · line */}| Part | Renders | Notes |
|---|---|---|
Separator (horizontal) | <hr> | 1px tall, full width. |
Separator (vertical) | <div role="separator"> | 1px wide, stretches to the parent's height (self-stretch). Has aria-orientation="vertical". |
Separator with label | <div role="separator"> | Horizontal only. A flex row with the label between two lines. |
Examples
Vertical
orientation="vertical" stretches to the height of a flex parent. Use it between groups in toolbars, nav rows and stat strips; add margin with mx-* and trim the height with my-*.
With label
label puts text in the line, for "or" dividers, dates in a feed or section titles. labelPosition moves it to the start, center (default) or end; the short side is 16px long. Labels only apply to horizontal separators.
Dashed
variant="dashed" draws a dashed line in either orientation, with or without a label. It reads as lighter than a solid rule, which suits drafts, timelines and optional sections.
Recipes
Sign-in options
The classic "or continue with" divider between social sign-in buttons and an email form.
Stat strip
Vertical separators between equal-width stats. They stretch to the row's height automatically.
Accessibility
- A horizontal separator renders a native
<hr>, which screen readers announce as a separator. - A vertical separator renders a
<div>withrole="separator"andaria-orientation="vertical", as<hr>is always horizontal. - A labelled separator is a
<div role="separator">. Screen readers generally don't read the content of a separator, so don't put essential information only in the label; "or" and dates are fine because the surrounding content carries the meaning. - Separators aren't focusable. Inside a React Aria
Toolbar, arrow-key navigation skips them. - React Aria only forwards a filtered set of DOM props (ids,
aria-label/aria-labelledby/aria-describedby,data-*and global attributes), soaria-hiddenisn't passed through on an unlabelled separator (a labelled one forwards every prop). If a line is purely decorative, draw it with aborder-*class on a neighboring element instead.
Styling
Data attributes
| Attribute | Present when |
|---|---|
data-slot="separator" | Always |
data-orientation | "horizontal" or "vertical". Always "horizontal" on labelled separators. |
Customizing
- The line color is
bg-border. Change it with abg-*class, e.g.bg-foreground/20. - Change thickness with
h-*(horizontal) orw-*(vertical). - For labelled separators,
classNamegoes on the flex row: change the label's text style there (text-sm text-foreground), or the line color withbefore:bg-* after:bg-*.
API Reference
Separator
Prop
Type
Without a label, also accepts the props of React Aria's Separator: aria-label, aria-labelledby, aria-describedby, data-* attributes, dir, lang, hidden and mouse, pointer and touch event handlers. With a label, the separator is a plain <div role="separator"> and every other prop (id, style, aria-*, data-*, event handlers, and so on) is forwarded to it unfiltered; only elementType, slot and render are dropped.
Related
- Card:
CardHeaderhas a built-in inset separator. - Menu:
MenuSeparatorbetween groups of menu items. - Item:
ItemSeparatorbetween list rows. - Toggle Button Group: grouped toolbar controls.