RE

React Focus Lock

react-focus-lock

It is a trap! (for a focus)

Utilities
react
focus
lock
trap
tabbable
react-focus-lock
Utilities
javascript
npm
frontend
Stars
1.4k
Weekly
3.1M
Open issues
6
Bundle
~25 kB

Installation

npm install react-focus-lock

Code example

import { useFocusLock } from "react-focus-lock";

export function Example() {
  const value = useFocusLock();
  return <p>{String(value)}</p>;
}

Pros & cons

Pros

  • Actively maintained by theKashey
  • 3.1M weekly downloads. Battle tested
  • First-class TypeScript definitions
  • MIT licensed

Considerations

  • Adds roughly ~25 kB to your bundle
  • Needs client-only rendering in SSR frameworks
  • Not supported in React Native
  • 6 open issues on GitHub

FAQs

Alternatives & similar libraries