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.

List

A short list of links or items, with or without bullets or numbers, as the native list. You choose bullets, numbers and spacing with a class. The list always has the list role, because a screen reader (software that reads the screen aloud) in Safari with VoiceOver can drop it from a list with no marker.

Package
@kvirn-ui/react
Testing
Automated. Core 0 of 2, Release 0 of 3

When to use it#

  • Use it for any short list: related links, footer links, what to bring, the steps of an application.
  • It has no marker. Add kv-list--bullet for bullets. Use as="ol" with kv-list--decimal when the order matters.
  • A list of links is a list, not a navigation. When it is navigation, put it in a nav with a name.
  • Not for a menu that marks the current page: use Navigation. Not for a label with its value: use a DefinitionList. Not for columns of data: use a Table.

Example#

Use cases#

Links to other services at the end of a page. Put them in a named nav, so screen reader users who jump between the page’s navigation areas can find them.

Warning: Don't forget

Give the nav a name. An unnamed nav is announced only as “navigation”, so people can’t tell it from the page’s other navigation areas (1.3.1 Info and Relationships, 2.4.1 Bypass Blocks).

How to apply for a parking permit

Steps in a fixed order. An ordered list tells a screen reader that the order matters, and the decimal class shows the numbers.

How to apply for a parking permit

  1. Fill in the application.
  2. Attach a copy of your vehicle registration.
  3. Wait for the decision. It arrives in your inbox on My pages.

Props in this example:

  • as on List.Root

Services with sub-services

Put an inner list inside the List.Item it belongs to. The bullet class marks each level.

Accessibility#

What it does for you#

  • APG pattern: none. List is static content, not a widget.
  • Deviations: none
  • Native elements used: <ul> (default) or <ol> with as="ol", and <li>. as is 'ul' | 'ol' only.

List is the native list with a class and a few typed choices, so link lists, related links and footer link groups are one component instead of a <ul role="list"> repeated per pattern. It adds no text, no behaviour and no tabindex. A list of links is a list, not a navigation: the consumer wraps it in a named nav when it is one.

PartElement / roleARIANotes
List.Root<ul> or <ol> → listrole="list", alwaysclass="kv-list", plus kv-list--bullet or -decimal for a marker, and kv-list--gap-2, -6 or -8 for another gap, all added by the consumer (the default adds none). WebKit and VoiceOver drop the list role under list-style: none, so the list always carries role="list". A role of your own wins
List.Item<li> → listitemnoneNo class, no role. Attributes and the ref reach the element. A link item is <List.Item><Link.Root href>…</Link.Root></List.Item>
List.Rootneverno name, tabindex, aria-hiddenNo aria-label by default. No heading, handler or live region

kv-list--decimal is for as="ol": on a ul the numbers say nothing about order to assistive technology. kv-list--bullet on an ol is allowed: the order is still announced.

It announces nothing.

What you need to do#

  • A list of links is a list, not a navigation. When it is navigation, wrap it in a <nav> with an accessible name (aria-label or aria-labelledby), and don't repeat the name inside it (1.3.1, 2.4.1).
  • Link text makes sense alone. Each link names its target without the text around it (2.4.4).
  • Use as="ol" when order matters, and kv-list--decimal only then (1.3.1).
  • Items are List.Item. Put nothing but List.Item directly in List.Root; a nested list goes inside an item.
  • Language. Text in another language goes in a nested KvirnProvider, with useLocale().localeProps on your own element (3.1.2).

Warning: Don't forget

Use the decimal class with as="ol", not with a plain list. On a plain list the numbers you see say nothing about order to a screen reader, so that information would be lost (1.3.1 Info and Relationships).

Visual and modes#

Headless: List ships no CSS. With @kvirn-ui/theme/theme.css, kv-list stacks the items with a gap between them, with no marker and no indent. bullet and decimal draw outside markers in the text colour, indented in rem (1.4.4). Target size and the focus indicator belong to the links inside. forced-colors: markers use the text colour, which the system maps. Motion: none.

Focus management#

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

Allowed elements#

A tag outside the list changes the page's outline or semantics (1.3.1, 4.1.2). List.Root takes ul (default) or ol; another tag warns once (as-not-allowed) and falls back to ul. List.Item is a native <li> and has no as.

WCAG success criteria#

  • 1.3.1 Info and Relationships (A), 4.1.2 Name, Role, Value (A): a list is a list with a count, with or without markers.
  • 1.4.4 Resize Text: sizes are in rem.

Keyboard#

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

API reference#

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

List.Root

Renders <ul>, or <ol> with as="ol", with the role list. It takes every attribute of a <ul> and passes ref to it. It has no state, no hook and no strings. Also exported as ListRoot. The default theme is described on Theming.

PropTypeDefaultDescription
as'ul' | 'ol''ul'Changes the element: use ol when the order matters. Only ul and ol are allowed.
refRef<HTMLElement>–Reaches the list, whichever element it is.
Class or attributeValuesMeaning
role"list", alwaysSafari and VoiceOver drop the list role when a list has no marker, so the role is always there. A role of your own wins.
kv-listalwaysThe part class: no marker and no indent. Your className joins it.
kv-list--bullet, kv-list--decimalclass you addA marker outside the text. Use decimal only with as="ol": numbers on a ul say nothing about order to assistive technology.
kv-list--gap-2, kv-list--gap-6, kv-list--gap-8class you addAnother space between the items. gap-2 is tighter than the default, gap-6 and gap-8 are wider.

List.Item

Renders <li> with no class and no role of its own. It takes every attribute of an <li> and passes ref to it. Also exported as ListItem. Put a Link or text in it, and a nested List.Root when the item has sub-items.

PropTypeDefaultDescription
refRef<HTMLLIElement>–Reaches the <li> element.

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/apasslist.stories.tsx, every story, 4 themes
Markup and ARIA (roles, names, ids, states)passn/apasslist.test.tsx › renders a ul or an ol with li items and keeps its class next to a consumer className; expectNoA11yViolations
Keyboard contract rows (Vitest browser)passn/apasslist.test.tsx › renders a ul or an ol with li items and keeps its class next to a consumer className (asserts no tabindex)
Focus order and managementn/an/an/anothing focusable: the component never takes or moves focus
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 + Windowspendingpendingpending
VoiceOver + Safari + iOSpendingpendingpending
Release (before 1.0 and each minor)
JAWS + Chrome + Windowspendingpendingpending
TalkBack + Chrome + Androidpendingpendingpending
VoiceOver + Safari + macOSpendingpendingpending