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.

Breadcrumb

A named landmark with the trail from the start page down to the page you are on, so a resident sees where they are and can go up a level. Each level above you is a link. The page you are on is plain text, so someone using the keyboard doesn’t stop on it.

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

When to use it#

  • Use it at the top of a page that sits two or more levels below the start page: a topic page, a service page, an article.
  • Put it before <main>, not in it, and give it a different name from any other <nav> on the page.
  • Put it in the same place on every page that has one. People look for it there (3.2.3 Consistent Navigation, AA).
  • List every level from the start page to the parent of the current page. It never collapses into “…”: a hidden level is a hidden way out, so a long trail wraps.
  • Not for the main menu: use Navigation. Not for moving between pages of a list: use Pagination. Not on the start page, which has no level above it.

Example#

Information: Implement like this

Register your router’s link once on the provider and every Breadcrumb.Link is rendered by it, so a click doesn’t reload the page. See the Next.js setup on KvirnProvider.

Use cases#

A page deep in the structure

A service page can sit five or six levels down. Write every level as a Breadcrumb.Link and the page you are on as Breadcrumb.Current. The trail wraps onto more lines instead of hiding the middle, so every way up stays visible, also on a screen 320px wide.

Warning: Don't forget

Name each link after the page’s title, as the page’s own heading says it: “Home care”, not “Click here” or “Level 3”. Mark no other item as the current page.

Your own name for the trail

In English the trail is named “You are here” by default. Give it another name with label when your service uses other words, or when the page has another navigation with that name. A screen reader lists landmarks by name, so two with the same name can’t be told apart.

Props in this example:

Warning: Don't forget

A name you write is your own text. If its language differs from the page, put the trail in a nested KvirnProvider and spread useLocale().localeProps on your own element around it (3.1.2 Language of Parts, AA).

Your own separator

The theme draws a chevron between the levels, and variant="slash" draws a slash. For anything else, such as an icon or a component of yours, pass it as separator on the root. It goes in every item, and the theme hides the first. The chevronForward icon from @kvirn-ui/icons flips itself in right-to-left text; an icon of your own needs mirrorInRtl.

Props in this example:

Warning: Don't forget

Keep a separator to decoration: nothing a keyboard can reach, such as a link or a button. Screen readers skip it, so anything focusable in it would be reachable but have no name (4.1.2 Name, Role, Value, A).

A trail in Swedish

The trail takes its name from the provider’s language: a Swedish provider gives it a Swedish name, and a Finnish provider a Finnish one. Give the provider the locale and its messages, and write no label. Here a nested provider keeps the rest of this page in English. The names of the levels are your own text, so this example writes them in Swedish too. A site that is in Swedish throughout sets the locale once, on the provider at the top.

Information: Did you know?

The name exists in all five languages. Have a native speaker check the text in each language you ship before you publish.

A trail in your own markup

When you write the elements yourself, call useBreadcrumb and spread each set of props on the element it names: the <nav>, the <ol>, each <li> and the last item’s <span>. You get the classes, the name, the list role and aria-current. Here the slash variant gives a path-like trail for a case system that staff use.

Props in this example:

  • variant on useBreadcrumb (options)
  • label on useBreadcrumb (options)

Warning: Don't forget

Give each link the class kv-breadcrumb-link: the hook doesn’t. The default theme uses it to keep the link tall enough to press (2.5.8 Target Size (Minimum), AA).

Accessibility#

What it does for you#

  • APG pattern: Breadcrumb: a <nav> named by a label around an ordered list of links.
  • Deviations: none. The current page is the last item as text (<span aria-current="page">), not a link to the page you are on. The APG makes aria-current optional when the current item is not a link; here it is set, so the current item is still exposed, and a link to the same page offers nothing to follow. The current page is simply not a Tab stop.
  • Native elements used: <nav> (the navigation landmark), <ol> and <li>. The links are Links: native <a href>, rendered by the registered router link.

A breadcrumb tells a resident where they are and gives a way up. It adds no tabindex, no key handling, no state and no announcement: the links are the focusable parts and own the keys.

PartElement / roleARIANotes
Breadcrumb.Root<nav> → navigationaria-label from label or breadcrumb.labelclass="kv-breadcrumb". Named, so a screen reader user finds it in the landmarks list. Place it before <main>, not in it
Breadcrumb.List<ol> → listrole="list"Ordered: the sequence is the meaning. The explicit role="list" keeps the list announced in Safari/VoiceOver, which drops it from a list with list-style: none (1.3.1 Info and Relationships, A)
Breadcrumb.Item<li> → listitemnoneHolds a Breadcrumb.Link, or the last item's Breadcrumb.Current
Breadcrumb.Link<a href> → linknoneA thin wrapper over Link.Root: the registered router link, the same props and ref
Breadcrumb.Current<span>aria-current="page"The page you are on: text, the last item, never a link. One aria-current per trail
SeparatorsCSS generated content, ::beforenoneEmpty alternative text, so never read. The chevron mirrors in RTL. Not in the markup. variant="slash" adds kv-breadcrumb--slash to the root and swaps the character
Custom separator<span class="kv-breadcrumb-separator">aria-hidden="true"From Breadcrumb.Root's separator, in every item; the theme hides the first one. Replaces the generated one. Decoration only: never interactive or focusable, and never in the accessibility tree
Partsas on Breadcrumb.Link onlynoneLink.Root's as: as="a" bypasses the router. Root, List, Item and Current have no as: the landmark and the list are fixed by the contract

It announces nothing.

What you need to do#

  • List every level from the home page to the current page's parent, each a link, then the current page as Breadcrumb.Current. It never collapses into "…": a hidden level is a hidden way out (2.4.8 Location, AAA, beyond the AA bar). It wraps onto more lines instead.
  • Do not link the current page, and mark no other item aria-current.
  • Link text is the page's title: "Start", not "Home link" or "Click here" (2.4.4 Link Purpose (In Context), A).
  • Put it in the same place on every page that has one. The trail is repeated on many pages, and people look for it in the same spot.
  • Breadcrumb supports, but doesn't satisfy, 2.4.5 Multiple Ways (AA). The site needs search or a site map as well.
  • Name two navigations differently when a page has another <nav>: this one is named You are here, so the other is not.
  • Language. A custom label is your own string: put it in a nested KvirnProvider with useLocale().localeProps on your own element if it differs from the page (3.1.2 Language of Parts, AA).
  • A custom separator is decorative. It is aria-hidden; if it needs a name, it is not a separator. Never put anything interactive or focusable in it (aria-hidden over focusable content is a mistake). The default chevron-forward mirrors itself in RTL; a registered or own icon needs mirrorInRtl. It is never the only cue between levels: the items are separate list items (1.4.1 Use of Color, A).
  • Keep the look in a custom theme. See Visual / modes.

Warning: Don't forget

A breadcrumb helps people move up, but it is not a way to find pages. Your site also needs search or a site map (2.4.5 Multiple Ways, AA).

Visual and modes#

  • Focus indicator: a link shows the focus ring (:focus-visible), through Link.
  • Target size: at least 24 by 24 pixels (2.5.8 Target Size (Minimum), AA).
  • Separators: the first item's separator is hidden (it is rendered in every item). A separator is never the only cue between levels, because the items are separate list items (1.4.1 Use of Color, A).
  • Reflow: the trail wraps at 320 pixels wide (1.4.10 Reflow, AA): the reflow sweep runs every story at 320 CSS px and fails on horizontal overflow.
  • Forced colours and reduced motion: the trail follows the system colours and nothing animates. The forced-colours and reduced-motion sweeps check it.

A custom theme must keep these.

Focus management#

  • Initial focus: not moved. Focus is never moved by the component.
  • Trap: no. Restore to: not applicable.
  • A link shows the focus ring (:focus-visible), through Link.

WCAG success criteria#

  • 1.1.1 Non-text Content (A): the separator is decoration, never read.
  • 1.3.1 Info and Relationships (A): a landmark, an ordered list, the current page.
  • 1.4.1 Use of Color (A): the current page is shown by text weight that differs from the links plus aria-current, not by colour.
  • 1.4.10 Reflow (AA): wraps at 320 pixels wide.
  • 1.4.11 Non-text Contrast (AA): a custom separator is decoration, so it has no contrast need.
  • 2.4.4 Link Purpose (In Context) (A): the link text is the page's title.
  • 2.5.8 Target Size (Minimum) (AA).
  • 3.1.2 Language of Parts (AA): a custom label in another language is marked by the consumer.
  • 4.1.2 Name, Role, Value (A).
  • 2.4.8 Location (AAA, beyond the AA bar): the trail shows where the page sits.

Designed and tested to meet WCAG 2.2 AA.

Keyboard#

Focus
native
Selection follows focus
n/a
Arrows wrap
n/a
Shortcuts
none

Native tab order. No key is intercepted, and the arrow keys do nothing.

KeyWhereWhat happens
Tabbefore / on the trailMoves to the next link, in order. The current page is not a stop, so the next Tab leaves the trail
Test: breadcrumb.test.tsx › Breadcrumb keyboard › Tab moves through the links in order and the current page is not a stop
Shift+Tabon a linkMoves to the previous link
Test: breadcrumb.test.tsx › Breadcrumb keyboard › Shift+Tab moves to the previous link
Enteron a linkFollows it: a router link navigates without a page load, and focus stays on the link
Test: breadcrumb.test.tsx › Breadcrumb keyboard › Enter follows a link through the registered router link, without a page load
Spaceon a linkNot handled (a link: the page scrolls natively)
Test: breadcrumb.test.tsx › Breadcrumb keyboard › Space is not handled

API reference#

import { Breadcrumb, useBreadcrumb } from '@kvirn-ui/react'

Breadcrumb.Root

Renders <nav>, the navigation landmark, named by the message breadcrumb.label or your label. It takes every attribute of a <nav> and passes ref to it. The default theme is described on Theming.

PropTypeDefaultDescription
variant'chevron' | 'slash''chevron'The separator the theme draws. slash adds kv-breadcrumb--slash; chevron adds no class. It is decoration with an empty text alternative.
separatorReactNode–Your own separator, rendered in every item (the theme hides the first one, and a custom theme must too): an Icon or a component. It is aria-hidden, so it must be decorative, never interactive. The chevronForward icon from @kvirn-ui/icons mirrors itself in RTL; an icon of your own needs mirrorInRtl.
labelstringthe message breadcrumb.labelThe accessible name, from your translations. Set as aria-label. An empty or whitespace-only label counts as none and the message is used.
messagesPartial<KvirnMessages['breadcrumb']>–Overrides breadcrumb.label for this trail.
Class or attributeValuesMeaning
kv-breadcrumbalwaysThe part class. The default theme styles it.
kv-breadcrumb--slashvariant="slash"Swaps the generated chevron for a slash. The default adds no class.
aria-labelthe nameAlways set, from label or the message breadcrumb.label.

Breadcrumb.List

Renders <ol> with the role list. It is ordered, because the sequence is the meaning.

Class or attributeValuesMeaning
kv-breadcrumb-listalwaysThe part class.

Breadcrumb.Item

Renders <li> with the role listitem. It holds a Breadcrumb.Link, or the last item’s Breadcrumb.Current.

Class or attributeValuesMeaning
kv-breadcrumb-itemalwaysThe part class. The default theme draws the separator before every item but the first.
kv-breadcrumb-separatorwhen the root has a separatorA span inside the item with aria-hidden="true", holding your separator.

Renders <a href>: a thin wrapper over Link.Root, so it is rendered by the router link you register on the provider. It takes the same props and ref as Link.Root, so as="a" skips the router link.

Class or attributeValuesMeaning
kv-breadcrumb-linkalwaysThe part class, next to kv-link.

Breadcrumb.Current

Renders <span> with aria-current="page". The page you are on, as text: the last item, never a link.

Class or attributeValuesMeaning
kv-breadcrumb-currentalwaysThe part class.
aria-current"page"Always set. Mark no other item in the trail.

useBreadcrumb

Options

PropTypeDefaultDescription
variant'chevron' | 'slash''chevron'The generated separator. slash adds kv-breadcrumb--slash to rootProps.
labelstringthe message breadcrumb.labelThe accessible name, set as aria-label. An empty label counts as none.
messagesPartial<KvirnMessages['breadcrumb']>–Per-instance message overrides: { label: "Where you are" }.

Result

PropTypeDefaultDescription
rootPropsBreadcrumbRootPartProps–Spread on the <nav>: the class and aria-label.
listPropsBreadcrumbListPartProps–Spread on the <ol>: the class.
itemPropsBreadcrumbItemPartProps–Spread on every <li>: the class.
currentPropsBreadcrumbCurrentPartProps–Spread on the current page’s <span>: the class and aria-current="page".
separatorPropsBreadcrumbSeparatorPartProps–Spread on a <span> you render inside an item for your own separator: the class and aria-hidden="true". The default theme hides the separator in the first item.
labelstring–The resolved name of the landmark.

Strings

These are the default texts in @kvirn-ui/i18n.

For your whole app, pass messages to KvirnProvider. For one Breadcrumb, pass its messages prop.

breadcrumb.label

The landmark’s accessible name, set as aria-label. It says what the trail is for.

LanguageDefault text
SvenskaDu är här
SuomiOlet tässä
Norsk bokmålDu er her
Norsk nynorskDu er her
EnglishYou are here

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/apassbreadcrumb.stories.tsx, every story, 4 themes
Markup and ARIA (roles, names, ids, states)passn/apassbreadcrumb.test.tsx (axe and role, name and state): is a navigation landmark named by the message breadcrumb.label
Keyboard contract rows (Vitest browser)passn/apass4 rows, each names a test in breadcrumb.test.tsx
Focus order and managementpassn/apassbreadcrumb.test.tsx asserts 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

What to check#

With a screen reader and the keyboard, try:

  • The landmarks list shows "You are here" (or your label) once.
  • Tab along the trail: each level is a link, in order. The current page is not a stop.
  • Reading the trail says "list" with the item count, and the current page as current.
  • Enter on a level goes there, and focus is not lost.
  • The separators are not read.
  • At 320px and in right-to-left text the trail wraps and the separators face the right way.