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.

SkipPanel

A list at the top of the page, shown when someone first presses Tab, with links that skip to the main content, the menu or the search, and the keyboard shortcuts the site offers. The whole panel is one Tab stop (a place where the Tab key stops). The first Tab lands on the first link and the next Tab leaves the panel. The Up and Down arrow keys move between the items. Every shortcut is also a row in the list, so nobody has to use the keys.

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

When to use it#

  • Use it when people often go to one of a few places first, such as the main content, the menu or the search. A municipality portal with a long header or a large menu is a good fit.
  • Add shortcut rows only for real actions, such as “Search” or “My cases”. Every shortcut also shows in the list as a button or link, so people who can’t use the keys lose nothing. Keep the same links and shortcuts on every page (3.2.3 Consistent Navigation, AA).
  • Put it first in the page, before the header and any other link. If the page also has a QuickExit, that comes first.
  • It stays one Tab stop however many items it has. Someone who wants the header presses Tab once, instead of tabbing through every shortcut on every page.
  • Keep it short: at most three skip links, five shortcuts and six items in all. A long list is slow to move through with the arrow keys.
  • Not for a skip link that must stay in the page flow, or where one target is enough, such as an e-service, a form or a page with a short header (about five Tab stops or fewer before the main content). Use a SkipLink instead.

Example#

Press Tab inside the example to see the panel. Use the Up and Down arrow keys to move through it, Tab to leave it, and Enter on a link to jump.

Use the up and down arrow keys to move between items.

Site header with a logo, a menu and a language switcher

The site navigation is here.

The main content starts here.

The page where you read about the keyboard shortcuts and turn them off is here.

Information: Did you know?

The panel floats over the top of the page. In these examples it floats inside the example frame so you can see it. See Visual and modes.

Use cases#

Shortcuts for the search and for My cases

Residents of a municipality often search the site or check their cases. A second group lists these two as rows. “Search” is a button that moves focus to the search field. “My cases” is a link. Each row has a chord: keys pressed together, such as Alt+Shift+S. Press the chord anywhere on the page, except in a text field, and the row runs as if you had pressed it. The help link goes last. In this example the links point to places on the same page. On your site, “My cases” points to the cases page. The help link points to the page where visitors read about the shortcuts and turn them off, such as /accessibility-settings#shortcuts.

Press Tab inside the example to see the panel. Or press Alt+Shift+S (Option+Shift+S on a Mac) anywhere on this page to search, and Alt+Shift+M for My cases.

Keyboard shortcuts

Use the up and down arrow keys to move between items.

The main content starts here.

Your open cases are listed here.

The page where you read about the keyboard shortcuts and turn them off is here.

Props in this example:

  • kind on SkipPanel.Label
  • shortcut on SkipPanel.Shortcut
  • as on SkipPanel.Shortcut
  • href on SkipPanel.HelpLink

Warning: Don't forget

Make every chord Alt (Option on a Mac) plus Shift plus a letter. Or use mod with a letter: it means Ctrl on Windows and Command on a Mac. A bare letter would fire while someone types or uses speech input (software that turns speech into text). It would also fall under 2.1.4 Character Key Shortcuts (Level A), which asks for a way to turn it off, change it or limit it to when its control has focus. In development, a warning flags a bare letter, Ctrl with Alt, and mod together with ctrl or meta.

Open the list again from a long list of cases

A caseworker has tabbed down a list of cases and wants the list of shortcuts again. Give the Root a reopenShortcut. The chord opens the list and focuses its first link. Escape closes it and puts focus back on the case they were on. The Hint (a line of instructions in the list) tells people which keys to press.

Press Tab inside the example to see the panel, then Tab through the cases. Press Alt+Shift+K (Option+Shift+K on a Mac) to open the list again, and Escape to go back to the case you were on.

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

Open cases

The page where you read about the keyboard shortcuts and turn them off is here.

Props in this example:

Information: Did you know?

A chord does nothing while focus is in a text field, a text area or a select, so it never stops someone from typing. The example has buttons and no text field, so the chord works wherever you tab. See the Keyboard section.

Let people turn the shortcuts off

A shortcut can clash with the keys of a screen reader (software that reads the screen aloud), the browser or the system. Connect shortcutsEnabled to a setting. When it is off, no chord works, the key names disappear and the second group’s label changes from “Keyboard shortcuts” to “Quick links”. The rows stay in the list. The HelpLink stays too, so a visitor who turned the shortcuts off can find the page that turns them on again.

Press Tab inside the example to see the panel. Turn the switch off and press Tab again: the panel now says Quick links and shows no keys. Alt+Shift+B (Option+Shift+B on a Mac) does nothing then.

Turn this off if the keys clash with your assistive technology or browser.

Use the up and down arrow keys to move between items.

The main content starts here.

The booking form opens here.

Props in this example:

Warning: Don't forget

Offer a setting that turns the shortcuts off, and keep it where people can find it: link to it with a HelpLink. 2.1.4 Character Key Shortcuts (Level A) asks for this for shortcuts that are only printable characters. Alt and Ctrl chords fall outside that rule, but the setting still helps when they clash with a screen reader or the browser.

Accessibility#

What it does for you#

  • APG pattern: none. WCAG technique G1 (a link at the top to skip to the main content) with C7 (hide it until it has focus), as SkipLink.
  • Deviations: the whole panel is one Tab stop, with arrow keys between its items (a "roving tabindex", the same idea as the APG toolbar), so a keyboard user passes it with one Tab. This differs from the APG keyboard practice and is an approved deviation. The panel has no dialog, menu or landmark role, no headings and no live region.
  • Native elements used: <div>, <ul>, <li>, <a href="#id">, <a href> (HelpLink), <button>, <kbd> (through Kbd), <p>.

SkipPanel is a list of links and buttons that is one Tab stop, with arrow keys between its items, first in the body. Shortcuts are page-wide chords (keys pressed together) that the consumer supplies; there are no defaults.

PartElement / roleARIANotes
Root<div class="kv-skip-panel">nonedata-collapsed after Escape on the floating list, data-reopened while opened by the reopen shortcut.
Group<div role="group">aria-labelledby → LabelNamed by visible text, not a heading
Label<span>noneskipPanel.skipToLabel, skipPanel.shortcutsLabel, or skipPanel.actionsLabel when shortcuts are off
List / Item<ul role="list"> / <li>nonerole="list" because list-style none drops the role in WebKit
Link<a href>aria-describedby on the first LinkThe first Link is described by the Hint's arrow sentence. Focuses its target, as SkipLink. Text skipPanel.mainContent or children
Shortcut<button type="button"> or as a linkaria-keyshortcuts="Alt+Shift+S"A mod chord is Meta+K on Apple platforms and Control+K elsewhere. Name is its text then the key caps ("Search Alt+Shift+S"), no aria-label (2.5.3 Label in Name, A). Key caps and aria-keyshortcuts are removed when shortcutsEnabled is false
HelpLink<a href>noneThe last item. A plain link in the roving set: follows its href natively, no focus-target logic. Text skipPanel.helpLink or children. Rendered while shortcutsEnabled is false
Hint<p> holding a <span id>noneThe arrow sentence in a <span id>, which the first Link's aria-describedby points at; then the reopen sentence only with a reopenShortcut and shortcuts enabled

It announces nothing.

What you need to do#

  • Put it first in the body, before the header; give each target an id. QuickExit comes before it when both are on a page.
  • Keep it short. The panel is one Tab stop, but a long list is slow to arrow through: at most 6 items in total, with at most 3 Links and at most 5 Shortcuts (the default theme is sized for this). For one link, use SkipLink.
  • Add a SkipPanel.HelpLink last, pointing at the page where a visitor reads the shortcuts and turns them off, for example <SkipPanel.HelpLink href="/accessibility-settings#shortcuts" />: it tells people who don't know the arrow keys where the rest is, and stays visible while shortcutsEnabled is false so shortcuts can be turned back on. Use as for a router link.
  • Put <SkipPanel.Hint /> inside Root. The first Link is described by it; without it a development warning says so.
  • Above a sticky header: the floating list sits above most page content. Raise its stacking order (the kv-skip-panel z-index) if your header is higher.
  • Pick chords with Alt or Option plus Shift and a letter, or mod (Command on Apple, Ctrl elsewhere) with a letter, such as { key: 'k', mod: true }. Never use mod together with ctrl or meta (a development warning). Check that Ctrl+K or Command+K doesn't clash with the browser or the screen reader. Never use a bare letter (2.1.4 Character Key Shortcuts, A), Ctrl+Alt (it is AltGr) or / (there is no such key on Nordic layouts). Windows' layout switch (Alt+Shift) can intercept some chords, and Firefox on Windows uses Alt+Shift+letter for HTML access keys.
  • Offer the off switch: wire shortcutsEnabled to a setting. 2.1.4 Character Key Shortcuts (A) covers only shortcuts made of printable characters, so Alt and Ctrl chords are outside it, but a bare letter is in scope. The switch is still offered because chords clash with the browser, the screen reader and the layout.
  • Mark a custom label in another language with its language (3.1.2 Language of Parts, AA).
  • Keep the skip links and shortcuts the same on every page (3.2.3 Consistent Navigation, AA).

Warning: Don't forget

Give every skip link a target with the id it points to. If the id is missing, the link goes nowhere and people using a keyboard must still tab through the whole header (2.4.1 Bypass Blocks, Level A). Put a Hint inside the Root, and add a HelpLink to the page where visitors can turn the shortcuts off.

Visual and modes#

Headless: the package ships no CSS. With the default theme the list is cut down to an empty box until focus is inside it, so keyboard and screen reader users can still reach it. When focus arrives, it shows as a panel that floats over the page, with no fade or other motion. It hides again as soon as focus leaves, so it never covers the next element that gets focus (2.4.11 Focus Not Obscured (Minimum), AA). On wide, tall screens it is fixed at the top of the window. On smaller screens, and at 400% zoom, it sits at the top of the page and scrolls with it, so it needs no scrollbar of its own (1.4.10 Reflow, AA). Each row is as tall as other controls (2.5.8 Target Size (Minimum), AA). In forced colours mode (the user's own system colours) it uses the system's text, background and link colours, and the highlight colour for the focus ring.

Warning: Don't forget

The floating list sits above the page by its stacking order (z-index). If a fixed header on your site sits above it, set a higher z-index on the kv-skip-panel class in your CSS. Otherwise the header can hide the item that has focus (2.4.11 Focus Not Obscured (Minimum), AA).

Focus management#

  • Initial focus: not moved.
  • The reopen shortcut remembers the focused element outside Root (never body) and focuses the first Link. Escape puts focus back on it, or on the first Link's target if it is gone or was body. The remembered element is forgotten when focus leaves the list.
  • Pressing a row with the mouse keeps focus in the list. Safari and Firefox on macOS don't focus a button when the mouse goes down, so without this the list would hide before the click lands.
  • Trap: no. Hidden by clipping (the list is cut to nothing but stays on the page, WCAG technique C7), never display: none.

WCAG success criteria#

  • 1.3.1 Info and Relationships (A): the group is named by visible text, and the lists are lists with items.
  • 1.4.10 Reflow (AA): the list sits in the page on small screens and at 400% zoom, and the reflow sweep checks every story for sideways scrolling at 320 CSS pixels.
  • 1.4.13 Content on Hover or Focus (AA): the panel shows on focus and hides when focus leaves.
  • 2.1.1 Keyboard (A): every item is reachable and operable by keyboard.
  • 2.1.2 No Keyboard Trap (A): Tab always leaves the panel.
  • 2.1.4 Character Key Shortcuts (A): shortcuts are chords with Alt or Ctrl and can be switched off.
  • 2.4.1 Bypass Blocks (A): the links jump to the main content.
  • 2.4.3 Focus Order (A): the panel is first, and the target keeps the order.
  • 2.4.7 Focus Visible (AA): the focused item shows a focus ring.
  • 2.4.11 Focus Not Obscured (Minimum) (AA): the panel hides as soon as focus leaves it.
  • 2.5.3 Label in Name (A): a shortcut's name is its text followed by its key caps.
  • 2.5.8 Target Size (Minimum) (AA): each row is as tall as other controls.
  • 3.2.1 On Focus (A): focus alone changes nothing.
  • 3.2.3 Consistent Navigation (AA): your duty; keep the panel the same on every page.
  • 4.1.2 Name, Role, Value (A): links and buttons are named by their text.

The behaviour ones are proved by tests and axe; the visual ones by stories and the sweeps.

Keyboard#

Focus
roving tabindex (one item has tabindex="0", the others -1; it resets to the first Link when focus leaves Root)
Selection follows focus
n/a
Arrows wrap
no (ArrowDown/ArrowUp, Home and End, vertical, across all groups in DOM order)
Shortcuts
consumer-supplied chords, bound on the document while Root is mounted and shortcutsEnabled. Opt-in: no defaults, and shortcutsEnabled={false} adds no listener.
KeyWhereWhat happens
Tabpage loadFocuses the first Link, which is described by the arrow sentence (aria-describedby); the list appears
Test: skip-panel.test.tsx › SkipPanel keyboard › Tab on page load focuses the first Link
Tabany itemLeaves the panel for the page's next stop; the list hides
Test: skip-panel.test.tsx › SkipPanel keyboard › Tab from any item leaves the panel for the page’s next stop
ArrowDown / ArrowUpon an item inside RootNext / previous item across all groups, in page order. They are not flipped in right-to-left layouts. The default browser action is stopped only when the key is handled
Test: skip-panel.test.tsx › SkipPanel keyboard › ArrowDown and ArrowUp move across both groups in order
ArrowLeft / ArrowRighton an itemNot handled, in LTR and RTL
Test: skip-panel.test.tsx › SkipPanel keyboard › the arrows are not flipped in RTL
ArrowDown / ArrowUpfirst / last itemStay on the item (no wrap)
Test: skip-panel.test.tsx › SkipPanel keyboard › the arrows do not wrap
Home / Endon an item inside RootFirst / last item
Test: skip-panel.test.tsx › SkipPanel keyboard › Home and End go to the first and last item
ArrowDown / ArrowUpon a collapsed listStill move; the focused item shows alone
Test: skip-panel.test.tsx › SkipPanel keyboard › the arrows still move on a collapsed card
ArrowDown / ArrowUp / Home / Endoutside RootNot handled
Test: skip-panel.test.tsx › SkipPanel keyboard › the arrows are not handled outside the card
(roving tabindex)focus leaves RootThe first Link is the Tab stop again, so the next entry starts at the first Link
Test: skip-panel.test.tsx › SkipPanel keyboard › only one item is a Tab stop, and it is the first Link again after focus leaves
Shift+Tabfirst itemLeaves the document (native); the list hides
Test: skip-panel.test.tsx › SkipPanel keyboard › Shift+Tab from the first item leaves the document
Shift+Tabany later itemLeaves the document backwards (native); the list hides
Test: skip-panel.test.tsx › SkipPanel keyboard › Shift+Tab from a later item leaves the document backwards
EnterLinkFocuses the target (tabindex=-1 until blur)
Test: skip-panel.test.tsx › SkipPanel keyboard › Enter on a Link focuses the target
EnterShortcut (button)Runs its action
Test: skip-panel.test.tsx › SkipPanel keyboard › Enter on a Shortcut button runs its action
EnterShortcut (link)Follows the link
Test: skip-panel.test.tsx › SkipPanel keyboard › Enter on a Shortcut link follows the link
SpaceShortcut (button)Runs its action (native)
Test: skip-panel.test.tsx › SkipPanel keyboard › Space on a Shortcut button runs its action
EnterHelpLinkFollows the link (native)
Test: skip-panel.test.tsx › SkipPanel keyboard › Enter on the HelpLink follows the link
ArrowDown / Endon the item before the HelpLinkReaches the HelpLink: it is the last item
Test: skip-panel.test.tsx › SkipPanel keyboard › ArrowDown and End reach the HelpLink, the last item
TabHelpLinkNot a Tab stop of its own (tabindex="-1"), except before hydration; reached by the arrows
Test: skip-panel.test.tsx › SkipPanel keyboard › the HelpLink is not a Tab stop but is reached by the arrows
SpaceLinkNot handled (native)
Test: skip-panel.test.tsx › SkipPanel keyboard › Space on a Link is not handled
Escapefloating, reached by TabCollapses the list so only the focused item stays visible (data-collapsed). Focus does not move. The list opens in full again when focus leaves the panel (1.4.13 Content on Hover or Focus, AA)
Test: skip-panel.test.tsx › SkipPanel keyboard › Escape on the floating card reached by Tab collapses it, focus stays, and leaving resets
Escapeopened by reopenShortcutCloses; focus returns to the element focused before
Test: skip-panel.test.tsx › SkipPanel keyboard › Escape on a card opened by the reopen shortcut closes it and focus returns
Escapeopened by reopenShortcut, element goneFocus goes to the first Link's target, never body
Test: skip-panel.test.tsx › SkipPanel keyboard › Escape focuses the first Link’s target when the element focused before is gone
reopenShortcutanywhere except a text field, enabledRemembers the focused element, focuses the first Link; the list shows
Test: skip-panel.test.tsx › SkipPanel keyboard › the reopen shortcut stores the focused element and focuses the first Link
a Shortcut's chordanywhere except a text field, enabledActivates that row, as if it was pressed
Test: skip-panel.test.tsx › SkipPanel keyboard › a Shortcut’s chord activates its row
a Shortcut's chordanywhere except a text field, enabledThe browser's own action is prevented
Test: skip-panel.test.tsx › SkipPanel keyboard › a Shortcut’s chord prevents the browser’s own action
any chorda text field or other place you type inNot handled
Test: skip-panel.test.tsx › SkipPanel keyboard › a chord is not handled in an editable target
a mod chordApple platformCommand+K; Ctrl+K doesn't match
Test: skip-panel.test.tsx › SkipPanel mod chords › a mod chord is Command+K on Apple platforms
a mod chordother platformsCtrl+K; Command+K doesn't match
Test: skip-panel.test.tsx › SkipPanel mod chords › a mod chord is Ctrl+K on other platforms
a mod chordAlt or Shift heldNot handled
Test: skip-panel.test.tsx › SkipPanel mod chords › a mod chord is not handled with Alt or Shift
any chordAltGr (used to type some characters)Not handled
Test: skip-panel.test.tsx › SkipPanel keyboard › a chord is not handled with AltGr
any chordextra Ctrl or MetaNot handled
Test: skip-panel.test.tsx › SkipPanel keyboard › a chord is not handled with an extra Ctrl or Meta
any chordshortcutsEnabled falseNot handled; no listener
Test: skip-panel.test.tsx › SkipPanel keyboard › no chord is handled while shortcutsEnabled is false
any chorda part of the page made inert (switched off)Not handled
Test: skip-panel.test.tsx › SkipPanel chords › no chord is handled inside an inert subtree
any chorda modal dialog is open and the list is not in itNot handled
Test: skip-panel.test.tsx › SkipPanel chords › no chord is handled while a modal dialog that does not hold the card is open
any chordApple platform, AltGraph reported with OptionHandled (Apple keyboards have no AltGr)
Test: skip-panel.test.tsx › SkipPanel chords › on Apple platforms AltGraph reported with Option does not reject the chord

The visible state (hidden before Tab, shown while focused, hidden after, not covering the next focused element) is proved by stories with the default theme loaded.

Information: Implement like this

For a chord with Ctrl on Windows and Command on a Mac, set mod instead of writing both. Command+K or Ctrl+K opens the row, and the key names and aria-keyshortcuts change to match. The other system’s key does not work. Check that the chord does not clash with your browser or screen reader.

<SkipPanel.Shortcut shortcut={{ key: 'k', mod: true }} onClick={focusSearch}>
  Search
</SkipPanel.Shortcut>

Announcements#

What a screen reader reads#

State or actionRead aloudPolitenessTest
Tab on page loadgroup, Skip to, then link, Main contentnoneskip-panel.test.tsx › SkipPanel read aloud › reads the skip group named by its Label, then its links
The first Linklink, Main content, Use the up and down arrow keys to move between items.noneskip-panel.test.tsx › SkipPanel read aloud › reads the first Link with the arrow-key description
Arrow to a Shortcut buttonbutton, Search Alt+Shift+S, key shortcuts Alt+Shift+S, in group, Keyboard shortcutsnoneskip-panel.test.tsx › SkipPanel read aloud › reads a Shortcut button with its key caps and its chord
A Shortcut rendered as a linklink, My cases Alt+Shift+M, key shortcuts Alt+Shift+Mnoneskip-panel.test.tsx › SkipPanel read aloud › reads a Shortcut link with its key caps and its chord
shortcutsEnabled falsegroup, Quick links, then button, Search (no chord)noneskip-panel.test.tsx › SkipPanel read aloud › with shortcutsEnabled false the group is Quick links and the button has no chord
The Hint in browse modeparagraph: Use the up and down arrow keys to move between items. Press Alt + Shift + K to open this list again.noneskip-panel.test.tsx › SkipPanel read aloud › reads the Hint as a paragraph with the chord
No Hint mountedthe first Link has no description (and a development warning)noneskip-panel.test.tsx › SkipPanel read aloud › without a Hint the first Link has no description and a development warning says so
A mod chord rowbutton, Search Ctrl+K, key shortcuts Control+K (Apple: Search Command+K, Meta+K)noneskip-panel.test.tsx › SkipPanel mod chords › a mod chord shows Command and Meta+K on Apple platforms and Ctrl and Control+K elsewhere (the read-aloud row for Alt+Shift+S proves the same phrasing)
The HelpLinklink, Keyboard help and settingsnoneskip-panel.test.tsx › SkipPanel read aloud › reads the HelpLink as a link with its default text
Escape collapsenothing spokennoneskip-panel.test.tsx › SkipPanel read aloud › Escape collapsing the card announces nothing

API reference#

import { SkipPanel, useSkipPanel } from '@kvirn-ui/react'

SkipPanel.Root

Renders <div class="kv-skip-panel"> with no role. It takes every attribute of a <div> and passes ref to it. It makes the panel one Tab stop by setting tabindex on its items, and handles the arrow, Home, End and Escape keys. Put it first in the body. The default theme is described on Theming.

PropTypeDefaultDescription
reopenShortcut{ key: string; mod?: boolean; alt?: boolean; shift?: boolean; ctrl?: boolean; meta?: boolean }–A chord that opens the list again from anywhere on the page, such as { key: "k", alt: true, shift: true }. It focuses the first link. There is no default chord. Add a Hint to tell people which keys it is.
shortcutsEnabledbooleantruefalse adds no keyboard listener, so no chord works, including reopenShortcut. It removes the key names from the rows and the aria-keyshortcuts attribute, and the Hint drops its sentence about the reopen keys. The rows and the HelpLink stay in the list as links and buttons.
Class or attributeValuesMeaning
kv-skip-panelalwaysThe part class. The default theme hides the list until it has focus.
data-collapsedpresent or absentSet after Escape on the list when someone reached it with Tab. Only the focused item stays visible. It clears when focus leaves the list.
data-reopenedpresent or absentSet while the list is open because of reopenShortcut. Escape clears it.

SkipPanel.Group

Renders <div role="group">, named by its Label. It takes every attribute of a <div>.

SkipPanel.Label

Renders <span> with the group’s visible name. It is not a heading.

PropTypeDefaultDescription
kind"skip" | "shortcuts""skip"Picks the default text. skip gives skipPanel.skipToLabel. shortcuts gives skipPanel.shortcutsLabel, or skipPanel.actionsLabel while shortcutsEnabled is false.
childrenReactNodethe message for kindYour own text. It replaces the message, so you set its language: mark it if it differs from the page.
messagesPartial<KvirnMessages['skipPanel']>–Overrides the messages for this label: { skipToLabel: "Go to" }.

SkipPanel.List

Renders <ul role="list">. The role keeps the list a list for screen readers when a style removes the bullets.

SkipPanel.Item

Renders <li>.

Renders <a href> with the role link. Activating it moves focus to the target, as SkipLink does. It takes every attribute of an <a> and passes ref to it.

PropTypeDefaultDescription
hrefstringRequiredA same-page address, "#main": the id of the element the link jumps to. A development warning says so when no element has the id.
childrenReactNodethe message skipPanel.mainContentYour own text. It replaces the message, so you set its language: mark it if it differs from the page.
messagesPartial<KvirnMessages['skipPanel']>–Overrides the message for this link: { mainContent: "The content" }.
asElementType'a'Changes the element to a component of your own, such as your design system’s link. It must render an <a href> and forward its ref. Don’t use Link.Root: a same-page address is not a route.
Class or attributeValuesMeaning
kv-skip-panel__linkalwaysThe part class.

SkipPanel.Shortcut

Renders <button type="button">, or a link with as. It shows your text and then the key names, each in a Kbd. It takes every attribute of the element and passes ref to it.

PropTypeDefaultDescription
shortcut{ key: string; mod?: boolean; alt?: boolean; shift?: boolean; ctrl?: boolean; meta?: boolean }RequiredThe chord, such as { key: "s", alt: true, shift: true } for Alt+Shift+S. Pressing it anywhere on the page, except in a text field, runs this row (it clicks the button or the link). Use Alt or Option with Shift and a letter, or mod with a letter. mod: true means Command on Apple platforms and Ctrl elsewhere, so { key: "k", mod: true } is Command+K on a Mac and Ctrl+K on other systems; the other system’s key does not match. Never a bare letter, and never Ctrl with Alt. A development warning flags both, and it flags mod together with ctrl or meta.
childrenReactNode–The row’s text, such as "Search". The key names follow it. A screen reader reads the text and then the keys.
asElementType'button'Makes the row a link, with "a" or your router’s link component. It must render an <a href> or a button and forward its ref. Without it the row is a <button type="button"> and you set onClick.
Class or attributeValuesMeaning
kv-skip-panel__shortcutalwaysThe part class.
aria-keyshortcuts"Alt+Shift+S", "Meta+K" or "Control+K"The chord in the form the ARIA specification uses. A mod chord is Meta+K on Apple platforms and Control+K elsewhere. It is removed while shortcutsEnabled is false.

Renders <a href> that goes last in the list, to the page where a visitor reads about the shortcuts and turns them off. It follows its address as any link does and moves no focus. The Up and Down arrow keys reach it, but it is not a Tab stop of its own. It stays in the list when shortcutsEnabled is false, so a visitor can turn the shortcuts back on. Its default text is “Keyboard help and settings”. It takes every attribute of an <a> and passes ref to it.

PropTypeDefaultDescription
hrefstringRequiredThe address of the page where a visitor reads about the shortcuts and turns them off, such as "/accessibility-settings#shortcuts". The link follows it as any link does. It does not move focus to a target on the same page.
childrenReactNodethe message skipPanel.helpLinkYour own text. It replaces the message, so you set its language: mark it if it differs from the page.
messagesPartial<KvirnMessages['skipPanel']>–Overrides the message for this link: { helpLink: "Shortcut settings" }.
asElementType'a'Changes the element to your router’s link component. It must render an <a href> and forward its ref.
Class or attributeValuesMeaning
kv-skip-panel__help-linkalwaysThe part class.

SkipPanel.Hint

Renders <p> with short instructions for the list. It always renders the arrow sentence, “Use the up and down arrow keys to move between items.” The first link is described by it, so a screen reader reads it when focus arrives. With a reopenShortcut and shortcuts on, it adds a second sentence, such as “Press Alt+Shift+K to open this list again.” Always put one inside the Root: without it a development warning says the first link has no description. It takes every attribute of a <p>.

useSkipPanel

The Root’s behaviour: the reopen and Escape state, and one keyboard listener on the document that exists only while shortcutsEnabled. It also makes the panel one Tab stop with the arrow, Home and End keys.

Options

PropTypeDefaultDescription
reopenShortcut{ key: string; mod?: boolean; alt?: boolean; shift?: boolean; ctrl?: boolean; meta?: boolean }–A chord that opens the list again and focuses the first link. No default.
shortcutsEnabledbooleantruefalse adds no listener and drops the key names and aria-keyshortcuts from the parts.

Result

PropTypeDefaultDescription
rootPropsSkipPanelPartProps–Spread on a <div>: the class, data-collapsed, data-reopened and the Escape, focus and mouse handlers.
listProps{ className, role: "list" }–Spread on a <ul>.
itemProps{ className }–Spread on a <li>.
hintProps{ className }–Spread on the <p> of your own hint.
rootRefRefObject<HTMLElement | null>–Set on the Root’s element. The reopen chord looks for the first link in it.
contextSkipPanelContextValue–What the parts share. SkipPanel.Root provides it; the part hooks read it.
collapsedboolean–true after Escape on the list reached with Tab.
reopenedboolean–true while the list is open because of reopenShortcut.

useSkipPanelGroup

It takes no options.

Result

PropTypeDefaultDescription
groupProps{ className, role: "group", aria-labelledby }–Spread on the group’s <div>. It points at the label.
labelProps{ className, id }–Spread on the label’s <span>, so the group is named by its visible text.

Options

PropTypeDefaultDescription
hrefstringRequiredA same-page address, "#main": the id of the element the link jumps to.
messagesPartial<KvirnMessages['skipPanel']>–Overrides the message skipPanel.mainContent for this link.

Result

PropTypeDefaultDescription
linkProps{ className, href, onClick }–Spread on an <a>. The click handler moves focus to the target, as SkipLink does.
labelstring–The message skipPanel.mainContent: the default text of the link.

useSkipPanelShortcut

It registers the chord with the Root while shortcutsEnabled, and gives the key names.

Options

PropTypeDefaultDescription
shortcut{ key: string; mod?: boolean; alt?: boolean; shift?: boolean; ctrl?: boolean; meta?: boolean }RequiredThe chord.
elementRefRefObject<HTMLElement | null>RequiredThe element the chord clicks. Set it on your row.

Result

PropTypeDefaultDescription
shortcutProps{ className, aria-keyshortcuts? }–Spread on your row. aria-keyshortcuts is left out while shortcuts are off.
keys{ key, text }[]–The key names in order, such as Alt, Shift, S. Option replaces Alt on Apple platforms. A mod chord gives Command on Apple platforms and Ctrl elsewhere. Empty while shortcuts are off.
joinerstring–The message keys.joiner, which goes between the key names.

It makes the link an item of the arrow-key set that is not a Tab stop of its own. It does not move focus to a target. It works while shortcutsEnabled is false.

Options

PropTypeDefaultDescription
messagesPartial<KvirnMessages['skipPanel']>–Overrides the message skipPanel.helpLink for this link.

Result

PropTypeDefaultDescription
helpLinkProps{ className }–Spread on an <a href> that you render.
labelstring–The message skipPanel.helpLink: the default text of the link.

useSkipPanelHint

It takes no options. Calling it tells the Root that a Hint exists, so the first link is described by it.

Result

PropTypeDefaultDescription
hintProps{ className }–Spread on a <p>.
arrowHint{ id, text }–The arrow-key sentence, always shown, and the id that the first link’s aria-describedby points at. Render the text in an element with that id.
sentence{ before, after } | undefined–The text around the reopen keys: before and after. It is undefined, so add nothing after the arrow sentence, when there is no reopenShortcut or shortcuts are off.
keys{ key, text }[]–The reopen chord’s key names in order.
joinerstring–The message keys.joiner, which goes between the key names.

Strings

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

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

skipPanel.skipToLabel

The name of the group of skip links, when you give the Label no text.

LanguageDefault text
SvenskaHoppa till
SuomiSiirry kohtaan
Norsk bokmålGå til
Norsk nynorskGå til
EnglishSkip to

skipPanel.mainContent

The link’s visible text, when you give the Link no children.

LanguageDefault text
SvenskaHuvudinnehåll
SuomiPääsisältö
Norsk bokmålHovedinnhold
Norsk nynorskHovudinnhald
EnglishMain content

skipPanel.shortcutsLabel

The name of the group of shortcuts, with kind="shortcuts".

LanguageDefault text
SvenskaKortkommandon
SuomiPikanäppäimet
Norsk bokmålHurtigtaster
Norsk nynorskSnøggtastar
EnglishKeyboard shortcuts

skipPanel.actionsLabel

The name of the second group instead of shortcutsLabel while shortcutsEnabled is false.

LanguageDefault text
SvenskaSnabblänkar
SuomiPikalinkit
Norsk bokmålHurtiglenker
Norsk nynorskSnøgglenkjer
EnglishQuick links

The HelpLink’s visible text, when you give it no children.

LanguageDefault text
SvenskaHjälp och inställningar för tangentbord
SuomiNäppäimistön ohje ja asetukset
Norsk bokmålTastaturhjelp og innstillinger
Norsk nynorskTastaturhjelp og innstillingar
EnglishKeyboard help and settings

skipPanel.arrowHint

The Hint’s first sentence. The first link is described by it.

LanguageDefault text
SvenskaAnvänd upp- och nedpilarna för att flytta mellan alternativen.
SuomiSiirry kohteiden välillä ylä- ja alanuolinäppäimillä.
Norsk bokmålBruk opp- og ned-piltastene for å bytte mellom valgene.
Norsk nynorskBruk opp- og ned-piltastane for å byte mellom vala.
EnglishUse the up and down arrow keys to move between items.

skipPanel.reopenHint

The Hint. {keys} is replaced by the key names of the reopenShortcut.

LanguageDefault text
SvenskaTryck på {keys} för att öppna listan igen.
SuomiAvaa tämä luettelo uudelleen painamalla {keys}.
Norsk bokmålTrykk {keys} for å åpne denne listen igjen.
Norsk nynorskTrykk {keys} for å opne lista igjen.
EnglishPress {keys} to open this list again.

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

The key names come from the keys messages. Have a native speaker review the Finnish and the two Norwegian names before you launch.

Message keyParametersDefault text in EnglishUsed for
shift–ShiftThe name of the Shift key in a row or the Hint.
alt–AltThe name of the Alt key.
option–OptionThe name of the Alt key on Apple platforms.
control–CtrlThe name of the Ctrl key.
command–CommandThe name of the Meta key on Apple platforms.
meta–MetaThe name of the Meta key on other platforms.
joiner–+The text between key names.

Known issues#

  • People who use a screen reader with a touch screen (VoiceOver on iOS, TalkBack) also hear the arrow-key sentence, which does not apply to them. The sentence is short; if it bothers your users, leave out SkipPanel.Hint, but then the first Link has no description and a warning appears in development.
  • In browse mode (the screen reader's reading mode) a screen reader reads every item with its own arrow keys, which matches the arrow hint. It may not announce the description on the first Link; test with your users' screen readers.
  • In Safari, Tab reaches links only when "Press Tab to highlight each item" is on (or with Option+Tab). Test with that setting on.
  • Until the page's script has loaded, the page has no roving tabindex (the single Tab stop), so every item is a Tab stop.
  • Alt+Shift+letter may not reach the page under NVDA and JAWS (browse and focus mode), Firefox, and Windows with two input layouts; test with your users' setups.
  • Screen readers may read the group names and the nested Kbd differently; test with your users' screen readers.
  • Screen-reader users who read from the top of the page hear the whole panel before the content, because the list is cut to nothing visually but still in the page (C7). They can jump to the main landmark or the h1.

Information: Did you know?

Test your chords with the screen readers and browsers your visitors use. Windows can use Alt+Shift to change the input language, and Firefox on Windows uses Alt+Shift with a letter for HTML access keys. Describe any clash in your accessibility statement. The rows in the list always work.

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/apassskip-panel.stories.tsx, every story, 4 themes
Markup and ARIA (roles, names, ids, states)passn/apassskip-panel.test.tsx › SkipPanel accessibility › has no axe violations; SkipPanel name and attributes › the lists are lists with items
Keyboard contract rows (Vitest browser)passn/apass35 rows, each names a test (skip-panel.test.tsx › SkipPanel keyboard › Tab on page load focuses the first Link)
Focus order and managementpassn/apassskip-panel.test.tsx asserts document.activeElement after each key; first: SkipPanel keyboard › Tab on page load focuses the first Link
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#

  • Press Tab once on a fresh page. The panel appears, focus is on the first link, and a screen reader reads the link and the arrow-key sentence.
  • Press the Up and Down arrow keys, then Home and End. Focus moves through the items in order and does not wrap around.
  • Press Tab again. Focus leaves the panel for the next stop on the page, and the panel hides.
  • Press Escape while the panel is open after a Tab. Only the focused item stays visible, and focus does not move.
  • With a reopen chord set, press it from the middle of the page, then press Escape. Focus goes back to where it was.
  • Press a shortcut's chord outside a text field, then inside one. The row runs outside the text field, and nothing happens inside it.