Skip to content
flyingsalmon

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/separator

Usage

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

  • Use Card to box content, because a card draws its own edge and separates by it.
  • Use Table to divide rows of data, because a table keeps a rule under every row already.

Do and don’t

  • Do
    Use 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.
  • Do
    Put 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.
  • Do
    Give 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’t
    Place a separator beside something that already draws a border.The boundary is already there, and a second line only doubles it.
  • Don’t
    Put 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.

PropTypeDefaultDescription
orientationSeparatorOrientationSeparatorOrientation.HorizontalHorizontal 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.
decorativebooleantrueWhen true the separator is hidden from assistive technology. Set false to announce it.

  • Card

    Draws its own edge instead of relying on rules.
  • Table

    Separates its own rows with rules.
  • Spacing

    The gap steps that set the rhythm around a rule.
  • Colours

    The border step the rule paints.