react-arrow-nav
TypeScript icon, indicating that this package has built-in type declarations

0.0.2 • Public • Published

React Keyboard Navigation

A simple react component to enable keyboard navigation through it's child components.

Installation

yarn add react-arrow-nav

OR

npm install react-arrow-nav

Usage

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.VERTICAL

    values = [ ArrowNav.VERTICAL , ArrowNav.HORIZONTAL , ArrowNav.BOTH ]

  • ...any other prop will be passed to the wrapping div element.

If the child elements are not DOM elements, make sure they pass down tabIndex prop to the DOM element

Package Sidebar

Install

npm i react-arrow-nav

Weekly Downloads

1

Version

0.0.2

License

MIT

Unpacked Size

13.4 kB

Total Files

9

Last publish

Collaborators

  • hadeeb