ui/integrations/keys-navigation
Navigation
DOM-driven navigation hooks for lists, menus, and tab bars with arrow keys, Home/End, and Enter/Space.
DOM-driven navigation hooks for lists, menus, and tab bars. Query elements by [role] and data-value attributes, handle arrow keys, Home/End, Enter/Space, and scroll-into-view.
Info:
For the complete API reference, see the @diffgazer/keys documentation.
useNavigation
Standalone hook — no KeyboardProvider required. Returns an onKeyDown handler for manual attachment.
tsx
Key options
DOM requirements
- Items must have
[role="${role}"]anddata-valueattributes, or thedata-diffgazer-navigation-itemcontract fromgetNavigationItemProps() - Calls
scrollIntoView({ block: "nearest" })on focus changes - Skips
[aria-disabled="true"]elements by default - Typed
data-diffgazer-navigation-itemvalues keep mixed widgets separate, for example option navigation does not pick up radio items in the same subtree
With @diffgazer/ui components
All navigation-enabled @diffgazer/ui components (Menu, Tabs, Select, RadioGroup, etc.) use useNavigation internally. See Patterns for integration examples.