Rokkit 1.0.0-next.128

Keyboard Navigation

Built-in keyboard navigation, ARIA support, and the navigator pattern

Every Rokkit component includes full keyboard navigation and ARIA support out of the box. No configuration required.

The Navigator Pattern

Rokkit uses a Svelte action called navigator that attaches keyboard handlers to any container element. Combined with a ListController, it provides:

  • Arrow key navigation (up/down, left/right)
  • Home/End to jump to first/last item
  • Enter/Space to select
  • Type-ahead search to jump to matching items
  • Proper ARIA roles and attributes
  • Focus management and visible focus indicators

Keyboard Shortcuts

KeyActionContext
ArrowDownMove to next itemLists, Menus, Selects
ArrowUpMove to previous itemLists, Menus, Selects
ArrowRightExpand group / next tabTrees, Tabs
ArrowLeftCollapse group / prev tabTrees, Tabs
HomeFirst itemAll
EndLast itemAll
Enter / SpaceSelect itemAll
EscapeClose dropdownSelect, Menu
Type characterJump to matching itemLists, Selects

Tree Navigation

In tree-style components (List with collapsible, Tree), the keyboard follows the WAI-ARIA TreeView pattern:

  • ArrowRight on a collapsed group — expands it
  • ArrowRight on an expanded group — moves focus to first child
  • ArrowLeft on a child — moves focus to parent group
  • ArrowLeft on an expanded group — collapses it
  • ArrowRight on a leaf item — does nothing (no children)

ARIA Support

Components automatically apply correct ARIA roles and attributes:

ComponentContainer RoleItem Role
Listnavigationbutton / link
Treetreetreeitem
Menumenumenuitem
Selectlistboxoption
Tabstablisttab

Selected items receive aria-selected="true", expanded groups get aria-expanded, and disabled items have aria-disabled="true".

Type-Ahead Search

In List and Select components, typing characters jumps to the first matching item. The search matches against the display text (the text field) and resets after a brief pause. This works automatically — no configuration needed.

Focus Management

When a dropdown opens (Select, Menu), focus moves to the first item or the currently selected item. When it closes, focus returns to the trigger element. Tab key moves focus out of the component entirely, following standard web behavior.

Related

  • List — Keyboard navigation in a persistent list
  • Select — Dropdown keyboard interaction
  • Tabs — Arrow key tab switching