Skip to
Keyboard shortcuts

Use the up and down arrow keys to move between items. Press Alt+Shift+K to open this list again.

Alpha version out now. The API may still change.

Divider

A line that marks where one topic ends and the next begins. It adds no text and does nothing when pressed. A screen reader (software that reads the screen aloud) may announce it as a separator. If the line is only decoration, you can tell screen readers to skip it.

Package
@kvirn-ui/react
Testing
Automated. Core n/a, Release n/a

When to use it#

  • Use it between two blocks on different topics, where a line helps people see where one ends and the next begins.
  • Keep a heading or some text on each side that says what the block is. The line does not say it, and it is not a heading. For a heading, use a Heading.
  • If the line is only decoration, tell screen readers to skip it. See A line that is only decoration.
  • Not for adding space between blocks. Use a layout such as a Stack.

Example#

Opening hours

Monday to Friday, 08:00 to 16:00.


Contact us

Call the citizen service on weekdays.

Use cases#

A line that is only decoration

The footnote below is not a new topic, so the line is only decoration. Pass role="presentation" and a screen reader skips the line instead of announcing a separator.

Call the citizen service on weekdays.

Last updated 1 October.

Warning: Don't forget

The line must not carry meaning alone. What the footnote is has to be clear from its text (1.3.1 Info and Relationships, Level A).

A stronger line between a decision and the next steps

The decision and the next steps are two topics, so the line stays a separator. Make it thicker and darker so it is easier to see. Set the CSS variables in your own stylesheet, on a class. The example sets them on the line so that it runs on its own.

Your decision

Your parking permit is approved.


What to do next

Pay the fee within 14 days to get the permit.

Warning: Don't forget

If you change the colour, keep the line clearly visible against the background when it matters to understanding (1.4.11 Non-text Contrast, Level AA).

Accessibility#

What it does for you#

  • APG pattern: none. Divider is static content, not a widget.
  • Deviations: none
  • Native elements used: <hr>. No as: the element is the semantics.

Divider is the native <hr> element with a class, so the theme can draw and space it. It adds no ARIA attributes, no text and no behaviour. An <hr> has the built-in role separator (a break between two topics), and some screen readers announce it.

PartElement / roleARIANotes
Divider<hr> → built-in separatornoneclass="kv-divider". Attributes and the ref reach the element unchanged
Divider<hr role="presentation">passed through by the consumerA purely visual line: not announced. The consumer chooses; the component never adds it
Dividerneverno tabindex, nameIt needs no accessible name and is not interactive

It announces nothing.

What you need to do#

  • Pick the role on purpose. Keep the default separator when the blocks on each side are different topics. Pass role="presentation" when the line is only decoration, so screen readers skip it (1.3.1 Info and Relationships, A).
  • Don't carry meaning in the line alone. What the line separates must also be clear from headings or text (1.3.1 Info and Relationships, A; 1.4.1 Use of Color, A).
  • Keep your own colour visible. If you change --kv-divider-color, keep the line clearly visible against the background when it matters to understanding (1.4.11 Non-text Contrast, AA).

Visual and modes#

Divider ships no CSS of its own. With the default theme it is a thin, faint line with space above and below. The space, width, style and colour are CSS variables you can change. The line is a border, not a background, so it stays visible in forced colours mode (the user's own system colours). Target size and focus indicator do not apply, because the line cannot be focused. There is no motion.

Focus management#

  • Initial focus: not moved. Divider never moves focus.
  • Trap: no.
  • Restore to: not applicable.

WCAG success criteria#

  • 1.3.1 Info and Relationships (A): a break between topics is the native <hr> and reads as a separator; a decorative one can be role="presentation" and reads nothing.
  • 1.4.11 Non-text Contrast (AA): the default line is decoration between blocks, and the content can be understood without it. If you make the line carry meaning, keep your own colour visible.

Keyboard#

Divider has no keys of its own. What you put in it keeps its own keys.

Announcements#

What a screen reader reads#

State or actionRead aloudPolitenessTest
<Divider /> between two paragraphsAbove, separator, … (the virtual reader adds orientation and value text), Belownonedivider.test.tsx › a default divider reads as a separator between the paragraphs
<Divider role="presentation" /> between themAbove, Below (no separator between the paragraphs)nonedivider.test.tsx › a presentation divider reads nothing between the paragraphs

API reference#

import { Divider } from '@kvirn-ui/react'

Divider

Renders <hr>, whose built-in role is separator. It takes every attribute of an <hr> and passes ref to it. It has no state, no hook and no as. With the default theme you change the line with the CSS variables below. Set them on the line, on a class or on any element above it. The default theme is described on Theming.

PropTypeDefaultDescription
refRef<HTMLHRElement>–Reaches the <hr> element.
Class or attributeValuesMeaning
kv-divideralwaysThe part class. The default theme draws the line and its margin with it. Your className joins it.
--kv-divider-widtha length, such as 2pxHow thick the line is. The default is the theme’s border width.
--kv-divider-stylea border style, such as dashedHow the line is drawn. The default is solid.
--kv-divider-colora colourThe colour of the line. The default is the theme’s faint border colour. Keep your own colour visible against the background when the line matters to understanding.
--kv-divider-margin-blocka lengthThe space above and below the line.
--kv-divider-margin-inlinea lengthThe space at the start and end of the line. The default is none.

Testing#

The automated tests prove the keyboard behaviour, the names and states, that axe finds no violations in every story and theme, and, for the components they cover, that the stories hold up in forced colours, reduced motion, text spacing and a 320 pixel width. An Automated row passes on these tests alone. A Core or Release row passes only when an automated agent check and a person on the real assistive technology have both checked it. "agent-verified" means automated tests in the repository (with a virtual screen reader for the screen reader rows), not the real assistive technology.

AT + browser + OSAgent checkHuman checkResultNotes
Automated (re-runnable tests)
axe, WCAG 2.2 A and AA, every story, 4 themespassn/apassdivider.stories.tsx, every story, 4 themes
Markup and ARIA (roles, names, ids, states)passn/apassdivider.test.tsx: a default divider reads as a separator between the paragraphs, a presentation divider reads nothing between the paragraphs, has no axe violations as a separator and as presentation
Keyboard contract rows (Vitest browser)passn/apass2 rows, each names a test in divider.test.tsx
Focus order and managementn/an/an/aan hr is not focusable
Display modes (forced colours, 320px reflow, text spacing, reduced motion)passn/apassthe four sweep projects (storybook-forced-colors, -reduced-motion, -reflow, -text-spacing), run in CI
Core (required for beta)
NVDA + Chrome + Windowsn/an/an/anative <hr> with its own separator role (or role="presentation" set by the consumer), no state or key handling; nothing to operate
VoiceOver + Safari + iOSn/an/an/anative <hr> with its own separator role (or role="presentation" set by the consumer), no state or key handling; nothing to operate
Release (before 1.0 and each minor)
JAWS + Chrome + Windowsn/an/an/anative <hr> with its own separator role (or role="presentation" set by the consumer), no state or key handling; nothing to operate
TalkBack + Chrome + Androidn/an/an/anative <hr> with its own separator role (or role="presentation" set by the consumer), no state or key handling; nothing to operate
VoiceOver + Safari + macOSn/an/an/anative <hr> with its own separator role (or role="presentation" set by the consumer), no state or key handling; nothing to operate