Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

roving-ux-react

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

roving-ux-react

Stateful roving index for react web ui

  • 1.2.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Roving UX React

Total Downloads Latest Release License

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 from NPM
import { useRovingIndex } from 'roving-ux-react'

Syntax

Quick API Overview

const {
  activeIndex, // index of the currently focused target
  roverProps, // props to assign to the rover
  getTargetProps, // getter function for each targets props, initialize with index
} = useRovingIndex()

const {
  tabIndex, // tabIndex for rover element, should always be -1
  onFocus, // focus handler to listen for nested elements receiving focus
  onKeyDown, // key event handler to listen for arrow key navigation
} = roverProps

Example Usage

import { useRovingIndex } from 'roving-ux-react'

// just one roving ux container
// roving-ux-react will use each child initialized with `getTargetProps` as target

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>
  )
}

Keywords

FAQs

Package last updated on 25 Jan 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc