Skip to content
Slotted

Divider

A line that separates two regions of content, announced as a separator or left out of the accessibility tree.

Billing

Invoices are issued on the first business day of each month.

Members

Eleven people in the Northwind operations team can approve orders.

Installation

The packages are a 0.x beta on npm, and their public API changes between beta releases without deprecation. One line installs the binding and the default theme.

bash
pnpm add @slotted/react @slotted/theme @slotted/themes

Separating two regions

A divider marks the boundary between two regions of content with one line. The plain rule is an hr, which already carries the separator role, so a screen reader announces the boundary without any attribute from the component. Use it where the content on each side is of the same kind, as in the example above. To space two blocks without a line, set the gap of a Stack instead.

Orientation

orientation sets the direction of the rule: horizontal, the default, or vertical. A horizontal rule takes the width of its container. A vertical rule stretches to the height of its row, whatever the alignment of the other items. A vertical rule sets aria-orientation="vertical", because a separator is horizontal unless it says otherwise.

horizontal42 open orders
17 shipped today
vertical
42 open orders
17 shipped today

Label

label interrupts the rule with a short text. A labelled rule is a div, because an hr takes no content, and it writes role="separator". React renders that element; in Angular, slDivider goes on a div you write. The text also becomes the accessible name through aria-label: the separator role makes its children presentational, so the visible text alone would leave the rule announced as empty. An aria-label of your own replaces it.

Pay with the card on file, ending in 4242.
Or
Send a bank transfer to Northwind Freight, reference INV-20418.

Label position

align places the label along the rule: start, center or end, in logical terms, so start is the right end in a right-to-left layout. The default is center. A label at one end keeps one half of the rule. It applies only to a rule that has a label.

Today
3 shipments left the Rotterdam warehouse.
Yesterday
5 shipments left, 1 was returned.
Earlier this week
11 shipments left, all delivered.

Vertical label

A vertical rule takes a label too. The text sits between two halves of the rule, and align places it along the height of the rule.

Pay by cardCharged todayReceipt by email
Or
Pay by transferDue in 30 daysReference INV-20418

Inset

inset stops the rule short of both ends of its container. The margin is the inline padding of a control, so a rule inside a list of rows lines up with their text. It applies to both orientations: a horizontal rule gains margin at its inline ends, a vertical rule at its block ends. Each card below holds rows of buttons: in the second, the rule starts where the text of the rows starts.

Full length



inset



Decorative

decorative removes the rule from the accessibility tree: the element takes role="none", so a screen reader announces no separator. Use it when the line groups content visually and a listener loses nothing by not hearing it. A rule without decorative is announced as a separator, and a labelled one is announced with its label as the name. A decorative labelled rule has no name; its text is read in document order, like any other text.

Announced

Order 20418 was packed.
Order 20418 was handed to the carrier.
Delivery
Order 20418 is due on Thursday.

decorative

Order 20418 was packed.
Order 20418 was handed to the carrier.
Delivery
Order 20418 is due on Thursday.

Between values

A row of figures separated by vertical rules is the common use of a vertical divider. The rules are decorative because the figures already carry their own labels. Each rule is as tall as the row.

Orders1,284

Revenue$48,200

Returns2.1%

Accessibility

  • The plain rule is an hr, which already exposes the separator role, so the component writes no role of its own.
  • A vertical rule receives aria-orientation, because a separator is horizontal unless it says otherwise.
  • decorative sets role="none". Use it when the rule groups content visually and a screen reader user loses nothing by not hearing it.
  • A labelled rule renders a div, because an hr takes no content. Its name comes from aria-label: the separator role makes its children presentational, so the visible label alone would leave the rule announced as empty.
  • A decorative rule carries no name, because role="none" prohibits one. Its label is read in document order, like any other text.
  • A rule rendered into another element — the li a menu separator has to be — receives role="separator", because only the hr carries that meaning by itself.
  • A role or an aria-label you pass is kept, so a rule that has to say something else keeps saying it.

API

divider

Props

orientation'horizontal' | 'vertical'Default horizontal
Sets the direction the rule runs in.
decorativebooleanDefault false
Removes the rule from the accessibility tree.
insetbooleanDefault false
Stops the rule short of both ends of its container.
labelstring
Short text that interrupts the rule. It is also the rule’s accessible name.
align'start' | 'center' | 'end'Default center
Sets the position of the label along the rule.
render(props) => ReactNode
Renders a different root element from the props it receives.

Theming

Each token is a CSS custom property: set it in a theme, or on any element to retune every divider inside it.

Divider tokens

TokenDefault
--slotted-divider-colorvar(--slotted-border-subtle, ButtonBorder)
--slotted-divider-gapvar(--slotted-space-4, 0.5rem)
--slotted-divider-insetvar(--slotted-control-padding-inline-md, 13px)
--slotted-divider-label-colorvar(--slotted-text-muted, GrayText)
--slotted-divider-min-length1em
--slotted-divider-thicknessvar(--slotted-border-width-thin, 1px)

Theme tokens it reads

TokenDefault
--slotted-border-subtleSet per scheme by the theme
--slotted-border-width-thin1px
--slotted-control-padding-inline-mdcomfortable 13px · compact 10px · dense 8px
--slotted-font-family-sans'Geist Variable', ui-sans-serif, system-ui, sans-serif
--slotted-font-size-xs0.75rem
--slotted-font-weight-medium500
--slotted-line-height-xs1.4
--slotted-space-40.5rem
--slotted-space-50.75rem
--slotted-text-mutedSet per scheme by the theme