react-untabbable
Advanced tools
Weekly downloads
Changelog
1.0.4 (May 10, 2020)
Readme
An extremely simple and tiny (1.3kB gzipped) utility to make a container and all its children untabbable, but still focusable. This can be useful in achieving a better accessibility for you components, like a menu with nested panels or the dreaded carousel where you probably want some of the items to be untabbable.
yarn add react-untabbable
or
npm i react-untabbable
It quite simply applies the value -1 to the tabbable elements inside a container, restoring afterwards when needed.
You can either use the hook or the component itself, pick what better suits your needs.
The component supports having more than 1 child and you can mix React elements with simples nodes (string, number, etc..). Elements must support receiving a ref.
Prop | Type | Default | Description |
---|---|---|---|
disabled | boolean | false | Restores the tabbable behaviour |
import { Untabbable } from 'react-untabbable';
<Untabbable>
<button>Can't tab into me 😢</button>
You can mix React elements with simple nodes! (string, number, etc...)
<div>
<button>Can't tab into me as well 😭</button>
</div>
</Untabbable>
Parameter | Type | Default | Description |
---|---|---|---|
ref | ref or ref[] | One or more refs to DOM elements | |
options? | object | {} | |
options.disabled | boolean | false | Restores the tabbable behaviour |
options.includeContainer | boolean | true | If the owner of the ref should also be untabbable |
import React, { useRef } from 'react';
import { useUntabbable } from 'react-untabbable';
const MyComponent = () => {
const firstButtonRef = useRef();
const secondButtonRef = useRef();
useUntabbable([firstButtonRef, secondButtonRef]);
return (
<div>
<button ref={firstButtonRef}>
Can't tab into me 😢
</button>
<div ref={secondButtonRef}>
<button>Can't tab into me as well 😭</button>
</div>
<button>Still tabbable 🎉</button>
</div>
);
};
FAQs
An extremely simple utility to make a container and all its children untabbable, but still focusable.
The npm package react-untabbable receives a total of 745 weekly downloads. As such, react-untabbable popularity was classified as not popular.
We found that react-untabbable demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket installs a Github app to automatically flag issues on every pull request and report the health of your dependencies. Find out what is inside your node modules and prevent malicious activity before you update the dependencies.