Skip to main content

Separator

Visually or semantically separates content.

When to use

  • Divide adjacent content without a box, in a row or in a column.
  • Put a text label in the middle or at one end of a horizontal divider: wrap the label and the separators in a HorizontalSeparatorGroup.
  • Prefer Card when the content needs a border on every side.
  • Prefer Well when the content needs a recessed background, not a line.
  • Prefer DescriptionList when the content is key and value pairs, which carry their own rows.

Vertical

Set orientation="vertical" to divide items in a row. The parent sets the height.

Semantic

A separator is decorative by default, and assistive technology skips it. Set semantic when the line marks a real boundary between two groups of content: it renders role="separator".

Labeled divider

Wrap a label and one or two separators in a HorizontalSeparatorGroup to put the label in the middle or at one end of the line.

Polymorphism

To render something else as a HorizontalSeparatorGroup or Separator, use the asChild prop to compose.

Color

The separator renders in the semantic separator color token: gray-500/20 in light and gray-600/20 in dark. This is the canonical divider color across mantle: Accordion dividers, DropdownMenu.Separator, Command.Separator, Select.Separator, and the rest all resolve to it.

Reuse the same color on your own dividers instead of hard-coding it:

API Reference

Separator

Visually or semantically separates content.

All props from div, plus:

PropTypeDefaultDescription
orientation?"horizontal" | "vertical""horizontal"The orientation of the separator, does it render horizontally or vertically.
semantic?booleanfalseIf true, the separator renders with all accessibility-related attributes and role="separator". If false, the separator is purely decorative and all accessibility-related attributes are updated so that the rendered element is removed from the accessibility tree.
asChild?booleanfalseUse the asChild prop to compose the Separator styling and functionality onto alternative element types or your own React components.
Data AttributeValueDescription
data-slot"separator"Names the part.
data-orientation"horizontal" | "vertical"The resolved orientation, after a HorizontalSeparatorGroup wins.
data-separatorpresentPresence-only. Lets a group exempt separators from shrink-0.

HorizontalSeparatorGroup

A container to layout a group of horizontal separators and other children. Overrides all children Separators to be orientation="horizontal". All props from div, plus:

PropTypeDefaultDescription
asChild?booleanfalseUse the asChild prop to compose the HorizontalSeparatorGroup styling and functionality onto alternative element types or your own React components.
Data AttributeValueDescription
data-slot"horizontal-separator-group"Names the part.
data-horizontal-separator-grouppresentPresence-only. Child separators stretch under it.