Skip to content
Cynosurev0.5.0
SearchStorybookGitHubnpmColour mode: System. Switch to Light

Components / Structure

Divider

A line that separates content: between sections of a page or card, or between items in a row. It can carry a short label such as "or". If the content only needs space between it, use the gap of Stack or Inline and no line.

Default

When to useLink to "When to use"

  • Horizontal (default): between sections of a page, a card or a panel that belong together but are different subjects.
  • Vertical: between items in a row, such as a footer of links or groups of buttons.
  • With a label: between two alternatives ("or"), or to head a group in a list ("Today").
  • tone="strong": when the quiet line is lost against a busy background.

Use something else when:

  • space alone separates the content well enough: Stack or Inline gap
  • the line separates groups of menu items: Menu draws its own
  • the section needs a title: Heading
  • the content should be framed as a unit: Card

UsageLink to "Usage"

tsx
Copy
import { Divider, Inline, Link, Stack } from "@arshad-shah/cynosure";

<Stack>
  <Profile />
  <Divider />
  <Billing />
</Stack>

<Divider>or</Divider>

<Inline>
  <Link href="/docs">Docs</Link>
  <Divider orientation="vertical" />
  <Link href="/privacy">Privacy</Link>
</Inline>

A divider has no margins of its own. The gap of the Stack or Inline around it usually gives the space; where there is none, spacing (sm, md, lg) adds space above and below a horizontal line, or before and after a vertical one.

VerticalLink to "Vertical"

A vertical divider stretches to the height of its row, also when the row centres its children. It needs a flex row to take its height from: Inline, Toolbar or any display: flex row. It ignores children: a label is drawn in horizontal lines only.

Vertical

LabelLink to "Label"

The label is drawn in the line. labelAlign places it at the start, center (default) or end; a start or end label sits flush with that edge, and both follow the text direction. Keep labels short.

DashedLink to "Dashed"

Dashed

PropsLink to "Props"

Every prop of Divider
PropWhat it doesTypeDefault
orientation
Direction of the line. A horizontal divider fills the width of its container; a vertical one stretches to the height of its flex row (Inline, Toolbar). Default "horizontal"."horizontal" | "vertical""horizontal"
variant
Line style. Default "solid"."solid" | "dashed""solid"
tone
Line colour: the quiet line colour, or a stronger one for emphasis. Default "neutral"."neutral" | "strong""neutral"
spacing
Space around the line along the flow: above and below a horizontal divider, before and after a vertical one. Stack and Inline gaps usually provide it. Default "none"."sm" | "md" | "lg" | "none""none"
labelAlign
Where the label sits along a horizontal line (follows the text direction). Default "center"."start" | "end" | "center""center"
decorative
Purely visual: not exposed as a separator. With false it has role="separator" and its label is its accessible name. Default true.booleantrue
className
Added to the root element, for layout.string
style
Layout only. Restyle through --cy-divider-* tokens.CSSProperties
children
A short label drawn in the line ("or"). Horizontal only: a vertical divider ignores it.ReactNode
data-testid
Set on the root element, to find it in tests.string

Generated from the type definitions in @arshad-shah/cynosure 0.5.0.

Behaviour and accessibilityLink to "Behaviour and accessibility"

Behaviour and accessibility, table 1
SettingWhat assistive technology gets
decorative (default)Nothing: the line has role="none". A label is read as plain text
decorative={false}role="separator". A label is its accessible name
decorative={false} and orientation="vertical"role="separator" with aria-orientation="vertical"
  • Decorative by default: most dividers repeat a structure that headings and landmarks already give. Set decorative={false} when the line itself marks a boundary the reader should know about, such as "Earlier messages" in a conversation.
  • Element: a div, not an hr, so that it can hold a label and stand vertically.
  • Orientation: horizontal is the default of the separator role, so aria-orientation is only set on a vertical separator.
  • Keyboard: none. A divider is never focusable.
  • Forced colours: the line is drawn with borders and stays visible in forced-colors mode.
  • Right to left: labelAlign="start" is the right edge and end the left edge.

TouchLink to "Touch"

Nothing in a divider can be pressed, so it has no hit area.

ThemingLink to "Theming"

Theming, table 2
TokenDefaultWhat it sets
--cy-divider-thickness--cy-border-widthThickness of the line
--cy-divider-color--cy-color-lineLine colour of the neutral tone
--cy-divider-color-strong--cy-color-mutedLine colour of the strong tone
--cy-divider-label-gap--cy-space-4Space between the label and the line on each side
--cy-divider-label-color--cy-color-mutedText colour of the label
--cy-divider-label-size--cy-font-size-smText size of the label
--cy-divider-spacing-{sm,md,lg}--cy-space-2, --cy-space-4, --cy-space-6Space around the line for each spacing value
ts
Copy
createTheme({ components: { divider: { thickness: "2px", labelSize: "0.75rem" } } });

className and style are for layout only (width, placement). Change the look through tokens so every product stays consistent.

Stack · Inline · Toolbar · Menu · Card

These examples run Cynosure 0.5.0 (commit 50ce30b), the version on npm.

Getting started
Theming
Icons
Accessibility
Code editors and highlighters
Using Cynosure without React
Build-tool adapters
Components
Accordion
AppShell
AspectRatio
Breadcrumbs
Calendar
Card
Container
Disclosure
Divider
DocumentViewport
Grid
Inline
PageHeader
PanZoomCanvas
ScrollArea
SideNav
SortableList
SplitPane
Stack
StatusBar
Tabs
TitleBar
Toolbar
Tree
VirtualList
ZoomControls
Announcer
Avatar
Badge
CodeBlock
DescriptionList
EmptyState
ErrorBoundary
Field
Heading
IconTile
Image
Kbd
List
LoadingDots
Notice
ProgressBar
Prose
Skeleton
Stat
Steps
Table
Text
Button
Checkbox
Checklist
ColorField
ColorSwatches
Combobox
CompareSlider
CopyButton
DateField
FileDrop
IconButton
KeyValueEditor
Link
NumberField
Pagination
PathField
RadioGroup
SearchField
SegmentedControl
Select
SelectionFrame
SignaturePad
Slider
Switch
TagInput
TextArea
TextField
ThemeToggle
TimeField
ButtonBase
ChoiceBase
DialogBase
FileInputBase
HiddenValue
Icon
InputBase
LinkBase
LiveRegion
TextAreaBase
ChatMessage
Choice
DataGrid
DeviceFrame
HighlightedText
HotkeyField
ListRow
OptionList
OverlayFrame
QRCode
RowActions
Section
SiteFooter
SiteHeader
SkipLink
SortButton
VisuallyHidden
CommandPalette
ContextMenu
Dialog
FloatingToolbar
HoverCard
Menu
Menubar
Popover
ProgressOverlay
Sheet
Toast
Tooltip
Changelog