Divider / Separator
FreeHorizontal and vertical dividers with solid/dashed/dotted/gradient/text/icon variants and start/center/end alignment.
</>sv-divider dividerseparatorlayout
import { SvDividerComponent } from '@styloviz/layout/divider';Demo & usage
Basic usage
Usage example — open the gallery for the full interactive demo.
An interactive demo for this component lives in the gallery.
Open live demoMore examples
Vertical & dashed
example.htmlAngular
2 lines
<sv-divider orientation="vertical" /> <sv-divider variant="dashed" spacing="my-8" />
Custom size
example.htmlAngular
2 lines
<sv-divider width="120px" /> <sv-divider orientation="vertical" height="24px" />
Decorative vs semantic
example.htmlAngular
6 lines
<!-- A visual flourish: nothing is announced --> <sv-divider semantics="decorative" variant="gradient" /> <!-- A section title is a HEADING, not a labelled divider --> <h2 class="text-sm font-semibold">Billing</h2> <sv-divider semantics="decorative" />
When to use
Separating content groups visually without adding semantic structure. Section breaks, "OR" separators between options, list/menu groupings. For grouping form fields with a heading, use the Input Group instead.
Async states
None — this component has nothing to load, so it has no loading, empty or error state to drive.
Inputs
| Name | Type | Default | Description |
|---|---|---|---|
| orientation | DividerOrientation | 'horizontal' | Layout direction: horizontal or vertical. |
| variant | DividerVariant | 'solid' | Line style: solid, dashed, dotted, gradient, text or icon. |
| align | DividerAlign | 'center' | Label/icon alignment: start, center or end. |
| label | string | '' | Optional inline text shown on the divider. |
| icon | string | '' | Name of an icon in `@styloviz/icons`, e.g. `'sparkles'`. A name, not a raw `<path d="…">` string: the library supplies the sizing, stroke and dark-mode handling. |
| color | string | '' | Custom line color (any CSS color). |
| thickness | number | 1 | Line thickness in pixels. |
| width | string | '' | Optional explicit width (any CSS length) — e.g. a short horizontal rule. |
| height | string | '' | Optional explicit height (any CSS length) — e.g. a fixed-height vertical rule that works without a stretched flex parent. |
| spacing | string | '' | Margin classes around the divider — Tailwind utilities, not a CSS length (e.g. `my-8`, or `mx-2` when vertical). Replaces the default `my-4` / `mx-4`, so `''` keeps the default and `my-0` removes it. |
| labelClass | string | '' | Extra CSS classes applied to the label. |
| semantics | DividerSemantics | 'semantic' | Whether this divider is a real thematic break (`semantic`) or a visual flourish (`decorative`). A divider — semantic or not — is not a heading. A labelled rule that visually introduces a section ("Billing") gives assistive technology no heading to navigate by; use a real `<h2>`–`<h6>` for that and, if you want the line too, a `decorative` divider beside it. - `semantic` → `role="separator"` + `aria-orientation` (+ `aria-label` from `label`). - `decorative` → `role="none"`; with no label the whole divider is also `aria-hidden`, so nothing at all is announced. |
Customization & theming
Solid, dashed, dotted and gradient lines. Inline text or icon label. Horizontal or vertical. Optional explicit `width` / `height`, custom `color` and `thickness`. `semantics`: `semantic` (default — a real thematic break) or `decorative` (a visual flourish, removed from the accessibility tree). Variant axes: `variant`, `color`, `thickness`, `align`, `spacing`, `width` / `height` are APPEARANCE; `orientation` is LAYOUT; `semantics` is MEANING and is independent of how the rule looks. Known limits: `gradient` ignores `color` and `thickness`; a vertical divider needs a height — a stretched flex-row parent or an explicit `height` — or it collapses to 1rem.
Best practices
Do: Use a labelled divider ("OR") to separate alternative actions. Do: Keep dividers subtle — they should organize, not dominate. Tip: Match `spacing` (margin utility classes such as `my-8`, replacing the default `my-4`) to the surrounding rhythm so sections breathe consistently. Don't: Don't use a labelled divider as a section title ("Billing", "Advanced settings"). It gives assistive technology no heading to jump to. Use a real `<h2>`–`<h6>` (or a `<fieldset>` + `<legend>` for form groups), and add a `semantics="decorative"` divider beside it if you want the line. Do: Mark purely visual rules — between cards, inside a hero, under a logo — `semantics="decorative"`, so a screen reader is not told "separator" between every flourish. Keep `semantic` for genuine topic changes. Tip: Layout: the host is `display: block; width: 100%` when horizontal and `inline-flex; align-self: stretch` when vertical — so a vertical divider takes its height from a flex row parent. Nothing is measured, portalled or scrolled. Tip: Platform limits: under Windows forced colours the solid, dashed and dotted variants are borders and repaint in the system colour; `gradient` is a background gradient, which forced colours drops, so under `forced-colors: active` it falls back to a 1px `CanvasText` border in the same orientation — the rule stays visible in every variant. Browsers omit backgrounds when printing by default, so a `gradient` rule may not print.
Accessibility
`semantics="semantic"` (the default) exposes `role="separator"` with `aria-orientation`, named by `label`. `semantics="decorative"` renders `role="none"`; an unlabelled decorative divider is also `aria-hidden`, so nothing is announced. A decorative divider with a `label` keeps the text readable in reading order ("OR" still means something) but announces no separator. A divider is not a heading. Screen-reader users navigate sections by headings, and a labelled rule gives them none — see the "Don't" under Best practices. RTL: `align="start"` / `"end"` are logical — the label sits on the right with `start` under `dir="rtl"` — and the vertical rule draws on the inline-start edge. Nothing in the divider names a physical side. Icon-only: the icon is decorative (`aria-hidden`) and gives the separator no name, so it must not carry meaning. When the icon says something ("end of results"), set `label` — it becomes the separator's accessible name — or use real text beside it. Contrast: the line is a decorative graphic, which WCAG 1.4.11 exempts — the default grey and the `gradient` (transparent at both ends) are deliberately quiet. Where the rule is the ONLY boundary between two interactive regions, set `color` to a token with at least 3:1 against the surface (e.g. `var(--color-gray-500)`) and use `solid`; under forced colours every variant already repaints in `CanvasText`.
Feedback on Divider / Separator
Spotted a gap in this page, or something that didn't work as described? Comments are GitHub Discussions in the public styloviz/community repo, so posting needs a GitHub account.