Divider
Divider separates sections of content or groups of items. It is a standalone
component (no upstream Spar primitive) that renders a semantic
role="separator" by default and draws its line entirely in CSS, so optional
label content can sit anywhere along the line.
Usage
import { Divider } from '@takeoff-ui/react-spar';
<Divider>OR</Divider>
Playground
Orientation
Vertical dividers stretch to the height of their flex container.
Appearances
Customization
- Line color — the line follows
currentColor; setcoloron the root viastyleor your own CSS. Dashed and dotted lines pick the color up too. - Spacing — outer margins default to
16px(margin-blockfor horizontal,margin-inlinefor vertical). Override them with inlinestyle(e.g.marginBlock), which always wins over the recipe. - Label — target the label slot with
classNames={{ label: … }}for extra classes orslotProps={{ label: { style: … } }}for inline styles. The gap between the line and the label is the label'spaddingInline(paddingBlockon vertical dividers),8pxby default.
Align
Use align to position the label along the line: start, center (the
default), or end.
API Reference
Divider
Props
| Name | Type | Default | Description |
|---|---|---|---|
| children | React.ReactNode | - | Label content rendered between the line segments. |
| orientation | DividerOrientation | 'horizontal' | Axis of the divider line. Vertical dividers size from their container — place them in a flex row (or give the parent an explicit height) so the line has a height to fill. |
| appearance | DividerAppearance | 'solid' | Line style. |
| align | DividerAlign | 'center' | Placement of the label along the divider line. |
| decorative | boolean | false | Marks the divider as purely visual. Decorative dividers are removed from the accessibility tree (role="none"); non-decorative dividers render role="separator" with the matching aria-orientation. |
| classNames | Partial<Record<DividerSlot, string>> | - | Per-slot extra classes. |
| slotProps | Partial<Record<DividerSlot, React.HTMLAttributes<HTMLElement>>> | - | Per-slot HTML-attribute overrides. |
| className | string | - | Appends custom classes to the root slot. |
Data attributes
| Attribute | Applied when | Purpose |
|---|---|---|
| data-slot="root" | Always | Stable selector for wrapper styling on the root slot. |
| data-slot="label" | When children are renderable | Stable selector for the wrapper-owned label slot. |
| data-orientation | Always | Reflects the resolved orientation prop for theme recipe scoping. |
| data-type | Always | Reflects the resolved appearance prop for theme recipe scoping. |
| data-align | Always | Reflects the resolved align prop that positions the label along the line. |
| role | Always | separator when the divider carries semantic meaning; none when decorative is true (removes the element from the accessibility tree). |
| aria-orientation | When decorative is false | Tells assistive technology the axis of the separator (horizontal | vertical). Absent on decorative dividers to avoid ARIA on a role="none" element. |
Type Definitions
| Name | Definition |
|---|---|
| DividerOrientation | 'horizontal' | 'vertical' |
| DividerAppearance | 'solid' | 'dashed' | 'dotted' |
| DividerAlign | 'start' | 'center' | 'end' |
| DividerSlot | 'root' | 'label' |