Skip to content

Divider

A thin rule that separates content. It can carry a label to name the section it opens.

tsx
import { Divider } from 'neba';

<Divider />
<Divider>OR</Divider>
<Divider orientation="vertical" />;

Props

PropTypeDefaultDescription
orientationshared'horizontal' | 'vertical''horizontal'Which way the line runs. A vertical rule has no height of its own: it stretches to its flex parent
colorshared'primary' | 'secondary' | 'success' | 'warning' | 'danger' | 'info''primary'Semantic colour role. The same hairline a Card scores its sections with
sizeshared'xs' | 'sm' | 'md' | 'lg' | 'xl''md'Type scale of the label. The line itself has no size
lengthnumber | stringHow far the rule runs: the width of a horizontal divider, the height of a vertical one. A number is pixels, a string is any CSS length. Left out, a horizontal rule is the full width of its container and a vertical one stretches to its flex row
thicknessnumber | string1How thick the rule is. A number is pixels, a string is any CSS length
childrenReactNodeA label set into the line. A string is copied into aria-label as well
textAlign'start' | 'center' | 'end''center'Where the label sits. Off-centre leaves a short stub on the near side

There is no variant and no elevation. The rule is drawn as a single border edge, so it takes no layout beyond its own thickness.

Examples

length and thickness

length is how far the rule runs (the width of a horizontal divider, the height of a vertical one), and thickness is how heavy it is. Both take a number of pixels or any CSS length. Left out, a horizontal rule fills its container and a vertical one stretches to the flex row it is in.

textAlign

A label in children splits the rule around it. center halves the line; start and end leave a short stub on the near side, so the label reads as set into the rule rather than floating above it.

orientation

vertical has no height of its own and stretches to its flex parent: the shape to use between control groups in a toolbar. A vertical label turns with the rule.

color

color applies to the rule only, and faintly.

Accessibility

  • Renders with role="separator".
  • separator does not take its accessible name from content, so a string label is also passed through as aria-label. A node is left alone, since only the caller knows which part of it is the name: set aria-label yourself if you need one.

Released under the MIT License