Components
Divider
A thin line that separates two groups of content, with an optional centred label, drawn as a neutral hairline and carrying no status or category colour.
Usage
pnpm dlx shadcn@latest add @opsinjs/divider
The @opsinjs namespace is declared in your components.json. Everything it installs is code you then own. There is no runtime package to keep in step.
import { Divider } from "@/components/ui/divider"<Divider />
<Divider label="Earlier" />
<Divider orientation="vertical" />Examples
divider · base base · style base-lyraOpen under the product themeA labelled boundary in a list
label marks the seam between today's items and the earlier ones. The two lists
carry the grouping on their own; the divider is the visible echo, not the only signal.
divider-a-labelled-group-boundary · base base · style base-lyraOpen under the product themeimport { Divider } from "@/components/ui/divider"
const TODAY = ["A note from this morning", "A reminder due later"]
const EARLIER = ["A note you wrote", "A reminder you set", "A page you opened"]
export default function DividerALabelledGroupBoundary() {
return (
<div className="flex w-full max-w-sm flex-col gap-opsin-2">
<h3 className="m-0 text-opsin-footnote [color:var(--muted-foreground)]">Today</h3>
<ul className="m-0 flex list-none flex-col gap-opsin-2 p-0">
{TODAY.map((item) => (
<li key={item} className="text-opsin-body [color:var(--foreground)]">
{item}
</li>
))}
</ul>
<Divider label="Earlier" />
<ul className="m-0 flex list-none flex-col gap-opsin-2 p-0">
{EARLIER.map((item) => (
<li key={item} className="text-opsin-body [color:var(--foreground)]">
{item}
</li>
))}
</ul>
</div>
)
}A vertical rule between inline facts
orientation="vertical" draws a hairline that takes its height from the flex row
around it. In a block that gives it no height it collapses to nothing.
divider-vertical-between-inline-facts · base base · style base-lyraOpen under the product themeimport { Divider } from "@/components/ui/divider"
export default function DividerVerticalBetweenInlineFacts() {
return (
<div className="flex items-center gap-opsin-3 text-opsin-footnote [color:var(--muted-foreground)]">
<span>Example label</span>
<Divider orientation="vertical" />
<span>Another label</span>
<Divider orientation="vertical" />
<span>A third label</span>
</div>
)
}When to use it
Use it when
- Between two stacked groups that are already distinct, to make the seam visible without giving either group a surface of its own.
- As a named boundary in a list, with a short label such as "Earlier" or "Today", echoing a grouping the list structure already carries.
- As a thin vertical rule between a few inline facts, inside a flex row that gives the rule its height.
Do not use it when
- You are grouping content that needs its own background, edge or padding, rather than a line between peers.Use
cardinstead. - You are separating layers of the interface by depth, such as a panel above the page.Use
surfaceinstead. - You are offering a choice between mutually exclusive views and the lines are really the seams between options.Use
segmented-controlinstead.
Accessibility
The audit changed nothing. The divider is not focusable and captures no key, in either
orientation, labelled or not. Unlabelled, the root exposes role="separator" with
aria-orientation, so a reader navigating by region can skip it. Labelled, the root
has no role, because a separator cannot carry an accessible name, and the label is
plain text between two aria-hidden hairlines. Every colour is a role token, no type
size is in px, and no banned word appears.
Residual items.
- A divider is never the only carrier of grouping for a screen reader, so the groups either side must be separated by structure too.
- The hairline's contrast against a card, a sheet and the page, and the labelled
form's footnote text against
--muted-foreground, are not yet measured. Both are shared role token pairs missing from the generated contrast table, so fixing either means editing the token set, outside this component's own file.
| Key | Action | Notes |
|---|---|---|
| Tab | Skips the divider | Not focusable and not a tab stop, in either orientation, labelled or not. |
| Shift+Tab | Skips the divider in reverse | Focus moves straight to the interactive element before it, in visual order. |
Contrast: 36 measured token pairs, 15 below floor
| Pair | Theme | APCA Lc | WCAG 2.2 | Floor |
|---|---|---|---|---|
| body text on the page | light | 101.6 | 17.18:1 | Pass |
| body text on the page | dark | -100.5 | 18.00:1 | Pass |
| body text on a card | light | 104.7 | 17.96:1 | Pass |
| body text on a card | dark | -99.6 | 16.32:1 | Pass |
| body text on the muted ground | light | 98.1 | 16.32:1 | Pass |
| body text on the muted ground | dark | -97.5 | 13.77:1 | Pass |
| secondary text on the page | light | 83.9 | 7.42:1 | Pass |
| secondary text on the page | dark | -80.7 | 13.44:1 | Pass |
| secondary text on a card | light | 87.0 | 7.76:1 | Pass |
| secondary text on a card | dark | -79.8 | 12.19:1 | Pass |
| secondary text on the muted ground | light | 80.4 | 7.05:1 | Pass |
| secondary text on the muted ground | dark | -77.8 | 10.28:1 | Pass |
| a hairline boundary on the page | light | 19.3 | 1.41:1 | Below floor |
| a hairline boundary on the page | dark | -8.2 | 1.90:1 | Below floor |
| a hairline boundary on a card | light | 22.4 | 1.47:1 | Below floor |
| a hairline boundary on a card | dark | -7.3 | 1.72:1 | Below floor |
| a hairline boundary on the muted ground | light | 15.8 | 1.34:1 | Below floor |
| a hairline boundary on the muted ground | dark | 0.0 | 1.45:1 | Below floor |
| a placeholder boundary on the page | light | 69.8 | 4.52:1 | Pass |
| a placeholder boundary on the page | dark | -51.0 | 7.62:1 | Pass |
| a placeholder boundary on a card | light | 72.8 | 4.72:1 | Pass |
| a placeholder boundary on a card | dark | -50.1 | 6.91:1 | Pass |
| a placeholder boundary on the muted ground | light | 66.2 | 4.29:1 | Pass |
| a placeholder boundary on the muted ground | dark | -48.1 | 5.83:1 | Pass |
| a placeholder fill on the page | light | 8.3 | 1.18:1 | Below floor |
| a placeholder fill on the page | dark | -8.2 | 1.90:1 | Below floor |
| a placeholder fill on a card | light | 11.4 | 1.23:1 | Below floor |
| a placeholder fill on a card | dark | -7.3 | 1.72:1 | Below floor |
| a placeholder fill on the muted ground | light | 0.0 | 1.12:1 | Below floor |
| a placeholder fill on the muted ground | dark | 0.0 | 1.45:1 | Below floor |
| a placeholder boundary on its own fill | light | 58.9 | 3.84:1 | Pass |
| a placeholder boundary on its own fill | dark | -41.5 | 4.01:1 | Below floor |
| the card hairline on the page | light | 69.8 | 4.52:1 | Pass |
| the card hairline on the page | dark | -28.7 | 4.19:1 | Below floor |
| the card hairline on a card | light | 72.8 | 4.72:1 | Pass |
| the card hairline on a card | dark | -27.9 | 3.80:1 | Below floor |
These are the measured token pairs this component draws colour from, not a measurement of the component itself.
Props interface
Prop
Type
Generated from DividerProps in registry/bases/base/divider.tsx.
orientation defaults to horizontal; an unknown value is drawn horizontal with
a development warning. label applies to the horizontal form only and is dropped
with a warning on a vertical rule. A whitespace-only label counts as none.
className is the only route by which colour can reach the component, and both
colour axes stay off it.