Skip to content
opsinjs
Edit this page

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

Theme
Density
Text
Status
Accent theme
Accent
divider · base base · style base-lyraOpen under the product theme

A 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.

Theme
Density
Text
Status
Accent theme
Accent
divider-a-labelled-group-boundary · base base · style base-lyraOpen under the product theme
divider-a-labelled-group-boundary.tsx
import { 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.

Theme
Density
Text
Status
Accent theme
Accent
divider-vertical-between-inline-facts · base base · style base-lyraOpen under the product theme
divider-vertical-between-inline-facts.tsx
import { 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 card instead.
  • You are separating layers of the interface by depth, such as a panel above the page.Use surface instead.
  • You are offering a choice between mutually exclusive views and the lines are really the seams between options.Use segmented-control instead.

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.
KeyActionNotes
TabSkips the dividerNot focusable and not a tab stop, in either orientation, labelled or not.
Shift+TabSkips the divider in reverseFocus moves straight to the interactive element before it, in visual order.
Contrast: 36 measured token pairs, 15 below floor
PairThemeAPCA LcWCAG 2.2Floor
body text on the pagelight101.617.18:1Pass
body text on the pagedark-100.518.00:1Pass
body text on a cardlight104.717.96:1Pass
body text on a carddark-99.616.32:1Pass
body text on the muted groundlight98.116.32:1Pass
body text on the muted grounddark-97.513.77:1Pass
secondary text on the pagelight83.97.42:1Pass
secondary text on the pagedark-80.713.44:1Pass
secondary text on a cardlight87.07.76:1Pass
secondary text on a carddark-79.812.19:1Pass
secondary text on the muted groundlight80.47.05:1Pass
secondary text on the muted grounddark-77.810.28:1Pass
a hairline boundary on the pagelight19.31.41:1Below floor
a hairline boundary on the pagedark-8.21.90:1Below floor
a hairline boundary on a cardlight22.41.47:1Below floor
a hairline boundary on a carddark-7.31.72:1Below floor
a hairline boundary on the muted groundlight15.81.34:1Below floor
a hairline boundary on the muted grounddark0.01.45:1Below floor
a placeholder boundary on the pagelight69.84.52:1Pass
a placeholder boundary on the pagedark-51.07.62:1Pass
a placeholder boundary on a cardlight72.84.72:1Pass
a placeholder boundary on a carddark-50.16.91:1Pass
a placeholder boundary on the muted groundlight66.24.29:1Pass
a placeholder boundary on the muted grounddark-48.15.83:1Pass
a placeholder fill on the pagelight8.31.18:1Below floor
a placeholder fill on the pagedark-8.21.90:1Below floor
a placeholder fill on a cardlight11.41.23:1Below floor
a placeholder fill on a carddark-7.31.72:1Below floor
a placeholder fill on the muted groundlight0.01.12:1Below floor
a placeholder fill on the muted grounddark0.01.45:1Below floor
a placeholder boundary on its own filllight58.93.84:1Pass
a placeholder boundary on its own filldark-41.54.01:1Below floor
the card hairline on the pagelight69.84.52:1Pass
the card hairline on the pagedark-28.74.19:1Below floor
the card hairline on a cardlight72.84.72:1Pass
the card hairline on a carddark-27.93.80:1Below 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.