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 main content starts here.
The page where you read about the keyboard shortcuts and turn them off is here.
import { SkipPanel } from '@kvirn-ui/react'
import { useSkipPanelTexts } from './texts.ts'
export function DefaultSkipPanel() {
const { texts } = useSkipPanelTexts()
return (
<div className="docs-skip-panel-example">
<p>
<small>{texts.hint}</small>
</p>
<SkipPanel.Root>
<SkipPanel.Group>
<SkipPanel.Label />
<SkipPanel.List>
<SkipPanel.Item>
<SkipPanel.Link href="#skip-panel-main" />
</SkipPanel.Item>
<SkipPanel.Item>
<SkipPanel.Link href="#skip-panel-navigation">{texts.navigationLabel}</SkipPanel.Link>
</SkipPanel.Item>
<SkipPanel.Item>
<SkipPanel.HelpLink href="#skip-panel-keyboard-help" />
</SkipPanel.Item>
</SkipPanel.List>
</SkipPanel.Group>
<SkipPanel.Hint />
</SkipPanel.Root>
<p>{texts.header}</p>
<div id="skip-panel-navigation">
<p>{texts.navigation}</p>
</div>
<div id="skip-panel-main">
<p>{texts.main}</p>
</div>
<div id="skip-panel-keyboard-help">
<p>{texts.keyboardHelp}</p>
</div>
</div>
)
}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.
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.
import { Field, SkipPanel, TextInput } from '@kvirn-ui/react'
import { useRef } from 'react'
import { useSkipPanelTexts } from './texts.ts'
export function Shortcuts() {
const { texts } = useSkipPanelTexts()
const searchRef = useRef<HTMLInputElement>(null)
return (
<div className="docs-skip-panel-example">
<p>
<small>{texts.hintShortcuts}</small>
</p>
<SkipPanel.Root>
<SkipPanel.Group>
<SkipPanel.Label />
<SkipPanel.List>
<SkipPanel.Item>
<SkipPanel.Link href="#skip-panel-shortcuts-main" />
</SkipPanel.Item>
</SkipPanel.List>
</SkipPanel.Group>
<SkipPanel.Group>
<SkipPanel.Label kind="shortcuts" />
<SkipPanel.List>
<SkipPanel.Item>
<SkipPanel.Shortcut
shortcut={{ key: 's', alt: true, shift: true }}
onClick={() => searchRef.current?.focus()}
>
{texts.searchLabel}
</SkipPanel.Shortcut>
</SkipPanel.Item>
<SkipPanel.Item>
<SkipPanel.Shortcut
as="a"
href="#skip-panel-shortcuts-cases"
shortcut={{ key: 'm', alt: true, shift: true }}
>
{texts.myCasesLabel}
</SkipPanel.Shortcut>
</SkipPanel.Item>
<SkipPanel.Item>
<SkipPanel.HelpLink href="#skip-panel-shortcuts-keyboard-help" />
</SkipPanel.Item>
</SkipPanel.List>
</SkipPanel.Group>
<SkipPanel.Hint />
</SkipPanel.Root>
<Field.Root>
<Field.Label>{texts.searchFieldLabel}</Field.Label>
<TextInput ref={searchRef} name="search" type="search" />
</Field.Root>
<div id="skip-panel-shortcuts-main">
<p>{texts.main}</p>
</div>
<div id="skip-panel-shortcuts-cases">
<p>{texts.myCases}</p>
</div>
<div id="skip-panel-shortcuts-keyboard-help">
<p>{texts.keyboardHelp}</p>
</div>
</div>
)
}Props in this example:
kindon SkipPanel.Labelshortcuton SkipPanel.Shortcutason SkipPanel.Shortcuthrefon 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.
import { Button, SkipPanel } from '@kvirn-ui/react'
import { useSkipPanelTexts } from './texts.ts'
export function Reopen() {
const { texts } = useSkipPanelTexts()
const cases = [texts.case1, texts.case2, texts.case3, texts.case4]
return (
<div className="docs-skip-panel-example">
<p>
<small>{texts.hintReopen}</small>
</p>
<SkipPanel.Root reopenShortcut={{ key: 'k', alt: true, shift: true }}>
<SkipPanel.Group>
<SkipPanel.Label />
<SkipPanel.List>
<SkipPanel.Item>
<SkipPanel.Link href="#skip-panel-reopen-main" />
</SkipPanel.Item>
<SkipPanel.Item>
<SkipPanel.HelpLink href="#skip-panel-reopen-keyboard-help" />
</SkipPanel.Item>
</SkipPanel.List>
</SkipPanel.Group>
<SkipPanel.Hint />
</SkipPanel.Root>
<div id="skip-panel-reopen-main">
<p>{texts.casesHeading}</p>
<ul>
{cases.map((caseText) => (
<li key={caseText}>
<Button>{caseText}</Button>
</li>
))}
</ul>
</div>
<div id="skip-panel-reopen-keyboard-help">
<p>{texts.keyboardHelp}</p>
</div>
</div>
)
}Props in this example:
reopenShortcuton SkipPanel.Root
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.
import { Field, SkipPanel, Switch } from '@kvirn-ui/react'
import { useState } from 'react'
import { useSkipPanelTexts } from './texts.ts'
export function TurnOff() {
const { texts } = useSkipPanelTexts()
const [shortcutsOn, setShortcutsOn] = useState(true)
return (
<div className="docs-skip-panel-example">
<p>
<small>{texts.hintTurnOff}</small>
</p>
<div id="skip-panel-turn-off-settings">
<Field.Root>
<Switch name="shortcuts" checked={shortcutsOn} onCheckedChange={setShortcutsOn} />
<Field.Label marker="none">{texts.useShortcuts}</Field.Label>
<Field.HelpText>{texts.switchHelp}</Field.HelpText>
</Field.Root>
</div>
<SkipPanel.Root shortcutsEnabled={shortcutsOn}>
<SkipPanel.Group>
<SkipPanel.Label />
<SkipPanel.List>
<SkipPanel.Item>
<SkipPanel.Link href="#skip-panel-turn-off-main" />
</SkipPanel.Item>
</SkipPanel.List>
</SkipPanel.Group>
<SkipPanel.Group>
<SkipPanel.Label kind="shortcuts" />
<SkipPanel.List>
<SkipPanel.Item>
<SkipPanel.Shortcut
as="a"
href="#skip-panel-turn-off-book"
shortcut={{ key: 'b', alt: true, shift: true }}
>
{texts.bookLabel}
</SkipPanel.Shortcut>
</SkipPanel.Item>
<SkipPanel.Item>
<SkipPanel.HelpLink href="#skip-panel-turn-off-settings" />
</SkipPanel.Item>
</SkipPanel.List>
</SkipPanel.Group>
<SkipPanel.Hint />
</SkipPanel.Root>
<div id="skip-panel-turn-off-main">
<p>{texts.main}</p>
</div>
<div id="skip-panel-turn-off-book">
<p>{texts.bookDone}</p>
</div>
</div>
)
}Props in this example:
shortcutsEnabledon SkipPanel.Roothrefon SkipPanel.HelpLink
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.
| Part | Element / role | ARIA | Notes |
|---|---|---|---|
| Root | <div class="kv-skip-panel"> | none | data-collapsed after Escape on the floating list, data-reopened while opened by the reopen shortcut. |
| Group | <div role="group"> | aria-labelledby → Label | Named by visible text, not a heading |
| Label | <span> | none | skipPanel.skipToLabel, skipPanel.shortcutsLabel, or skipPanel.actionsLabel when shortcuts are off |
| List / Item | <ul role="list"> / <li> | none | role="list" because list-style none drops the role in WebKit |
| Link | <a href> | aria-describedby on the first Link | The 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 link | aria-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> | none | The 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> | none | The 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.HelpLinklast, 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 whileshortcutsEnabledis false so shortcuts can be turned back on. Useasfor 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-panelz-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 usemodtogether withctrlormeta(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
shortcutsEnabledto 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 wasbody. 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, andshortcutsEnabled={false}adds no listener.
| Key | Where | What happens |
|---|---|---|
| Tab | page load | Focuses the first Link, which is described by the arrow sentence (aria-describedby); the list appearsTest: skip-panel.test.tsx › SkipPanel keyboard › Tab on page load focuses the first Link |
| Tab | any item | Leaves 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 / ArrowUp | on an item inside Root | Next / 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 / ArrowRight | on an item | Not handled, in LTR and RTL Test: skip-panel.test.tsx › SkipPanel keyboard › the arrows are not flipped in RTL |
| ArrowDown / ArrowUp | first / last item | Stay on the item (no wrap) Test: skip-panel.test.tsx › SkipPanel keyboard › the arrows do not wrap |
| Home / End | on an item inside Root | First / last item Test: skip-panel.test.tsx › SkipPanel keyboard › Home and End go to the first and last item |
| ArrowDown / ArrowUp | on a collapsed list | Still move; the focused item shows alone Test: skip-panel.test.tsx › SkipPanel keyboard › the arrows still move on a collapsed card |
| ArrowDown / ArrowUp / Home / End | outside Root | Not handled Test: skip-panel.test.tsx › SkipPanel keyboard › the arrows are not handled outside the card |
| (roving tabindex) | focus leaves Root | The 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+Tab | first item | Leaves the document (native); the list hides Test: skip-panel.test.tsx › SkipPanel keyboard › Shift+Tab from the first item leaves the document |
| Shift+Tab | any later item | Leaves the document backwards (native); the list hides Test: skip-panel.test.tsx › SkipPanel keyboard › Shift+Tab from a later item leaves the document backwards |
| Enter | Link | Focuses the target (tabindex=-1 until blur)Test: skip-panel.test.tsx › SkipPanel keyboard › Enter on a Link focuses the target |
| Enter | Shortcut (button) | Runs its action Test: skip-panel.test.tsx › SkipPanel keyboard › Enter on a Shortcut button runs its action |
| Enter | Shortcut (link) | Follows the link Test: skip-panel.test.tsx › SkipPanel keyboard › Enter on a Shortcut link follows the link |
| Space | Shortcut (button) | Runs its action (native) Test: skip-panel.test.tsx › SkipPanel keyboard › Space on a Shortcut button runs its action |
| Enter | HelpLink | Follows the link (native) Test: skip-panel.test.tsx › SkipPanel keyboard › Enter on the HelpLink follows the link |
| ArrowDown / End | on the item before the HelpLink | Reaches the HelpLink: it is the last item Test: skip-panel.test.tsx › SkipPanel keyboard › ArrowDown and End reach the HelpLink, the last item |
| Tab | HelpLink | Not a Tab stop of its own (tabindex="-1"), except before hydration; reached by the arrowsTest: skip-panel.test.tsx › SkipPanel keyboard › the HelpLink is not a Tab stop but is reached by the arrows |
| Space | Link | Not handled (native) Test: skip-panel.test.tsx › SkipPanel keyboard › Space on a Link is not handled |
| Escape | floating, reached by Tab | Collapses 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 |
| Escape | opened by reopenShortcut | Closes; 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 |
| Escape | opened by reopenShortcut, element gone | Focus goes to the first Link's target, never bodyTest: skip-panel.test.tsx › SkipPanel keyboard › Escape focuses the first Link’s target when the element focused before is gone |
| reopenShortcut | anywhere except a text field, enabled | Remembers 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 chord | anywhere except a text field, enabled | Activates that row, as if it was pressed Test: skip-panel.test.tsx › SkipPanel keyboard › a Shortcut’s chord activates its row |
| a Shortcut's chord | anywhere except a text field, enabled | The browser's own action is prevented Test: skip-panel.test.tsx › SkipPanel keyboard › a Shortcut’s chord prevents the browser’s own action |
| any chord | a text field or other place you type in | Not handled Test: skip-panel.test.tsx › SkipPanel keyboard › a chord is not handled in an editable target |
| a mod chord | Apple platform | Command+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 chord | other platforms | Ctrl+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 chord | Alt or Shift held | Not handled Test: skip-panel.test.tsx › SkipPanel mod chords › a mod chord is not handled with Alt or Shift |
| any chord | AltGr (used to type some characters) | Not handled Test: skip-panel.test.tsx › SkipPanel keyboard › a chord is not handled with AltGr |
| any chord | extra Ctrl or Meta | Not handled Test: skip-panel.test.tsx › SkipPanel keyboard › a chord is not handled with an extra Ctrl or Meta |
| any chord | shortcutsEnabled false | Not handled; no listener Test: skip-panel.test.tsx › SkipPanel keyboard › no chord is handled while shortcutsEnabled is false |
| any chord | a 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 chord | a modal dialog is open and the list is not in it | Not 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 chord | Apple platform, AltGraph reported with Option | Handled (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 action | Read aloud | Politeness | Test |
|---|---|---|---|
| Tab on page load | group, Skip to, then link, Main content | none | skip-panel.test.tsx › SkipPanel read aloud › reads the skip group named by its Label, then its links |
| The first Link | link, Main content, Use the up and down arrow keys to move between items. | none | skip-panel.test.tsx › SkipPanel read aloud › reads the first Link with the arrow-key description |
| Arrow to a Shortcut button | button, Search Alt+Shift+S, key shortcuts Alt+Shift+S, in group, Keyboard shortcuts | none | skip-panel.test.tsx › SkipPanel read aloud › reads a Shortcut button with its key caps and its chord |
| A Shortcut rendered as a link | link, My cases Alt+Shift+M, key shortcuts Alt+Shift+M | none | skip-panel.test.tsx › SkipPanel read aloud › reads a Shortcut link with its key caps and its chord |
shortcutsEnabled false | group, Quick links, then button, Search (no chord) | none | skip-panel.test.tsx › SkipPanel read aloud › with shortcutsEnabled false the group is Quick links and the button has no chord |
| The Hint in browse mode | paragraph: Use the up and down arrow keys to move between items. Press Alt + Shift + K to open this list again. | none | skip-panel.test.tsx › SkipPanel read aloud › reads the Hint as a paragraph with the chord |
| No Hint mounted | the first Link has no description (and a development warning) | none | skip-panel.test.tsx › SkipPanel read aloud › without a Hint the first Link has no description and a development warning says so |
A mod chord row | button, Search Ctrl+K, key shortcuts Control+K (Apple: Search Command+K, Meta+K) | none | skip-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 HelpLink | link, Keyboard help and settings | none | skip-panel.test.tsx › SkipPanel read aloud › reads the HelpLink as a link with its default text |
| Escape collapse | nothing spoken | none | skip-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.
| Prop | Type | Default | Description |
|---|---|---|---|
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. |
shortcutsEnabled | boolean | true | false 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 attribute | Values | Meaning |
|---|---|---|
kv-skip-panel | always | The part class. The default theme hides the list until it has focus. |
data-collapsed | present or absent | Set 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-reopened | present or absent | Set 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.
| Prop | Type | Default | Description |
|---|---|---|---|
kind | "skip" | "shortcuts" | "skip" | Picks the default text. skip gives skipPanel.skipToLabel. shortcuts gives skipPanel.shortcutsLabel, or skipPanel.actionsLabel while shortcutsEnabled is false. |
children | ReactNode | the message for kind | Your own text. It replaces the message, so you set its language: mark it if it differs from the page. |
messages | Partial<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>.
SkipPanel.Link
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.
| Prop | Type | Default | Description |
|---|---|---|---|
href | string | Required | A same-page address, "#main": the id of the element the link jumps to. A development warning says so when no element has the id. |
children | ReactNode | the message skipPanel.mainContent | Your own text. It replaces the message, so you set its language: mark it if it differs from the page. |
messages | Partial<KvirnMessages['skipPanel']> | – | Overrides the message for this link: { mainContent: "The content" }. |
as | ElementType | '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 attribute | Values | Meaning |
|---|---|---|
kv-skip-panel__link | always | The 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.
| Prop | Type | Default | Description |
|---|---|---|---|
shortcut | { key: string; mod?: boolean; alt?: boolean; shift?: boolean; ctrl?: boolean; meta?: boolean } | Required | The 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. |
children | ReactNode | – | The row’s text, such as "Search". The key names follow it. A screen reader reads the text and then the keys. |
as | ElementType | '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 attribute | Values | Meaning |
|---|---|---|
kv-skip-panel__shortcut | always | The 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. |
SkipPanel.HelpLink
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.
| Prop | Type | Default | Description |
|---|---|---|---|
href | string | Required | The 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. |
children | ReactNode | the message skipPanel.helpLink | Your own text. It replaces the message, so you set its language: mark it if it differs from the page. |
messages | Partial<KvirnMessages['skipPanel']> | – | Overrides the message for this link: { helpLink: "Shortcut settings" }. |
as | ElementType | 'a' | Changes the element to your router’s link component. It must render an <a href> and forward its ref. |
| Class or attribute | Values | Meaning |
|---|---|---|
kv-skip-panel__help-link | always | The 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
| Prop | Type | Default | Description |
|---|---|---|---|
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. |
shortcutsEnabled | boolean | true | false adds no listener and drops the key names and aria-keyshortcuts from the parts. |
Result
| Prop | Type | Default | Description |
|---|---|---|---|
rootProps | SkipPanelPartProps | – | 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. |
rootRef | RefObject<HTMLElement | null> | – | Set on the Root’s element. The reopen chord looks for the first link in it. |
context | SkipPanelContextValue | – | What the parts share. SkipPanel.Root provides it; the part hooks read it. |
collapsed | boolean | – | true after Escape on the list reached with Tab. |
reopened | boolean | – | true while the list is open because of reopenShortcut. |
useSkipPanelGroup
It takes no options.
Result
| Prop | Type | Default | Description |
|---|---|---|---|
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. |
useSkipPanelLink
Options
| Prop | Type | Default | Description |
|---|---|---|---|
href | string | Required | A same-page address, "#main": the id of the element the link jumps to. |
messages | Partial<KvirnMessages['skipPanel']> | – | Overrides the message skipPanel.mainContent for this link. |
Result
| Prop | Type | Default | Description |
|---|---|---|---|
linkProps | { className, href, onClick } | – | Spread on an <a>. The click handler moves focus to the target, as SkipLink does. |
label | string | – | 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
| Prop | Type | Default | Description |
|---|---|---|---|
shortcut | { key: string; mod?: boolean; alt?: boolean; shift?: boolean; ctrl?: boolean; meta?: boolean } | Required | The chord. |
elementRef | RefObject<HTMLElement | null> | Required | The element the chord clicks. Set it on your row. |
Result
| Prop | Type | Default | Description |
|---|---|---|---|
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. |
joiner | string | – | The message keys.joiner, which goes between the key names. |
useSkipPanelHelpLink
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
| Prop | Type | Default | Description |
|---|---|---|---|
messages | Partial<KvirnMessages['skipPanel']> | – | Overrides the message skipPanel.helpLink for this link. |
Result
| Prop | Type | Default | Description |
|---|---|---|---|
helpLinkProps | { className } | – | Spread on an <a href> that you render. |
label | string | – | 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
| Prop | Type | Default | Description |
|---|---|---|---|
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. |
joiner | string | – | 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.
| Language | Default text |
|---|---|
| Svenska | Hoppa till |
| Suomi | Siirry kohtaan |
| Norsk bokmål | Gå til |
| Norsk nynorsk | Gå til |
| English | Skip to |
skipPanel.mainContent
The link’s visible text, when you give the Link no children.
| Language | Default text |
|---|---|
| Svenska | Huvudinnehåll |
| Suomi | Pääsisältö |
| Norsk bokmål | Hovedinnhold |
| Norsk nynorsk | Hovudinnhald |
| English | Main content |
skipPanel.shortcutsLabel
The name of the group of shortcuts, with kind="shortcuts".
| Language | Default text |
|---|---|
| Svenska | Kortkommandon |
| Suomi | Pikanäppäimet |
| Norsk bokmål | Hurtigtaster |
| Norsk nynorsk | Snøggtastar |
| English | Keyboard shortcuts |
skipPanel.actionsLabel
The name of the second group instead of shortcutsLabel while shortcutsEnabled is false.
| Language | Default text |
|---|---|
| Svenska | Snabblänkar |
| Suomi | Pikalinkit |
| Norsk bokmål | Hurtiglenker |
| Norsk nynorsk | Snøgglenkjer |
| English | Quick links |
skipPanel.helpLink
The HelpLink’s visible text, when you give it no children.
| Language | Default text |
|---|---|
| Svenska | Hjälp och inställningar för tangentbord |
| Suomi | Näppäimistön ohje ja asetukset |
| Norsk bokmål | Tastaturhjelp og innstillinger |
| Norsk nynorsk | Tastaturhjelp og innstillingar |
| English | Keyboard help and settings |
skipPanel.arrowHint
The Hint’s first sentence. The first link is described by it.
| Language | Default text |
|---|---|
| Svenska | Använd upp- och nedpilarna för att flytta mellan alternativen. |
| Suomi | Siirry kohteiden välillä ylä- ja alanuolinäppäimillä. |
| Norsk bokmål | Bruk opp- og ned-piltastene for å bytte mellom valgene. |
| Norsk nynorsk | Bruk opp- og ned-piltastane for å byte mellom vala. |
| English | Use the up and down arrow keys to move between items. |
skipPanel.reopenHint
The Hint. {keys} is replaced by the key names of the reopenShortcut.
| Language | Default text |
|---|---|
| Svenska | Tryck på {keys} för att öppna listan igen. |
| Suomi | Avaa tämä luettelo uudelleen painamalla {keys}. |
| Norsk bokmål | Trykk {keys} for å åpne denne listen igjen. |
| Norsk nynorsk | Trykk {keys} for å opne lista igjen. |
| English | Press {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 key | Parameters | Default text in English | Used for |
|---|---|---|---|
shift | – | Shift | The name of the Shift key in a row or the Hint. |
alt | – | Alt | The name of the Alt key. |
option | – | Option | The name of the Alt key on Apple platforms. |
control | – | Ctrl | The name of the Ctrl key. |
command | – | Command | The name of the Meta key on Apple platforms. |
meta | – | Meta | The 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 + OS | Agent check | Human check | Result | Notes |
|---|---|---|---|---|
| Automated (re-runnable tests) | ||||
| axe, WCAG 2.2 A and AA, every story, 4 themes | pass | n/a | pass | skip-panel.stories.tsx, every story, 4 themes |
| Markup and ARIA (roles, names, ids, states) | pass | n/a | pass | skip-panel.test.tsx › SkipPanel accessibility › has no axe violations; SkipPanel name and attributes › the lists are lists with items |
| Keyboard contract rows (Vitest browser) | pass | n/a | pass | 35 rows, each names a test (skip-panel.test.tsx › SkipPanel keyboard › Tab on page load focuses the first Link) |
| Focus order and management | pass | n/a | pass | skip-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) | pass | n/a | pass | the four sweep projects (storybook-forced-colors, -reduced-motion, -reflow, -text-spacing), run in CI |
| Core (required for beta) | ||||
| NVDA + Chrome + Windows | pending | pending | pending | |
| VoiceOver + Safari + iOS | pending | pending | pending | |
| Release (before 1.0 and each minor) | ||||
| JAWS + Chrome + Windows | pending | pending | pending | |
| TalkBack + Chrome + Android | pending | pending | pending | |
| VoiceOver + Safari + macOS | pending | pending | pending |
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.