Roving UX React
Turns tedious tab UX into a controlled and stateful experience
Inspired by roving-ux by Adam Argyle
Learn more in this article by Rob Dodson on web.dev
Try it at this GUI Challenge (use tab
then left || right
arrows)
Features & Why
1️⃣ User's shouldn't need to tab through each item in a list to see the next list
2️⃣ Providing keyboard list UX should be easy
3️⃣ Maintaining the last focused element should be easy
Getting Started
Installation
npm i roving-ux-react
Importing
import { useRovingIndex } from 'roving-ux-react'
Syntax
Quick API Overview
const {
activeIndex,
roverProps,
getTargetProps,
} = useRovingIndex()
const {
tabIndex,
onFocus,
onKeyDown,
} = roverProps
Example Usage
import { useRovingIndex } from 'roving-ux-react'
function Carousel() {
const { roverProps, getTargetProps } = useRovingIndex()
return (
<ul {...roverProps}>
<li {...getTargetProps(0)}>Item #1</li>
<li {...getTargetProps(1)}>Item #2</li>
<li {...getTargetProps(2)}>Item #3</li>
</ul>
)
}