React Keyboard Navigation
A simple react component to enable keyboard navigation through it's child components.
Installation
yarn add react-arrow-navOR
npm install react-arrow-navUsage
Import Component
import ArrowNav from "react-arrow-nav";
class TodoItem extends React.Component {
render() {
<ArrowNav>
<div>Item 1</div>
<div>Item 2</div>
<FancyItem>Item 3</FancyItem>
</ArrowNav>;
}
}
function FancyItem({ tabIndex, children }) {
return (
<button {...fancyProps} tabIndex={tabIndex}>
{children}
</button>
);
}Props
-
mode
The direction of keyboard navigation.
default :
ArrowNav.VERTICALvalues = [
ArrowNav.VERTICAL,ArrowNav.HORIZONTAL,ArrowNav.BOTH] -
...any other prop will be passed to the wrapping
divelement.
If the child elements are not DOM elements, make sure they pass down
tabIndexprop to the DOM element
On this page
Languages
TypeScript85.3%JavaScript14.7%
Contributors
MIT License
Created December 2, 2020
Updated December 2, 2020