2.0 alpha
These docs describe 2.0. Install it with @once-ui-system/core@alpha.
On 1.8.x? Read the 1.x docs
TrademarkTrademarkDocs
Ctrl k
Search docs...
Hooks

useArrowNavigation

Updated: February 22, 2026
View on GitHub
The useArrowNavigation hook provides keyboard navigation for interactive elements using arrow keys. It supports row, column, and grid layouts with customizable behavior. Used in components: DropdownWrapper, EmojiPicker, Select, ContextMenu, MegaMenu
  • Arrow key navigation (up, down, left, right)
  • Support for row, column, and grid layouts
  • Automatic focus management
  • Enter/Space key selection
  • Optional wrapping at boundaries
  • Visual focus highlighting
  • ARIA-compliant accessibility
Add arrow navigation to a list: Navigate a grid with arrow keys: Navigate horizontally:
Prop
Type
Default
layout
'row''column''grid'
itemCount
number
columns
number8
containerRef
RefObject<HTMLElement>
onSelect
(index: number) => void
onFocusChange
(index: number) => void
wrap
booleantrue
initialFocusedIndex
number-1
itemSelector
string'[role="option"], [data-value], button'
autoFocus
booleanfalse
disabled
booleanfalse
disableHighlighting
booleanfalse
  • Arrow Up: Move focus up (column/grid)
  • Arrow Down: Move focus down (column/grid)
  • Arrow Left: Move focus left (row/grid)
  • Arrow Right: Move focus right (row/grid)
  • Enter/Space: Select focused item
  • Home: Focus first item
  • End: Focus last item
Use the focusedIndex to style the focused item: The hook automatically manages:
  • Focus visibility with visual indicators
  • ARIA roles and attributes
  • Keyboard event handling
  • Focus trap within container
For best accessibility, add appropriate ARIA attributes: This hook is used internally by:
  • EmojiPicker
  • Dropdown
  • Select
  • ContextMenu
  • MegaMenu
Edit this page on GitHub
TrademarkTrademark
Built with curiosity by Lorant One and the Design Engineers Club