REACT FOCUS LOCK

- browser friendly focus lock
- matching all your use cases
- trusted by best UI frameworks
- the thing Admiral Ackbar was talking about
[](https://circleci.com/gh/theKashey/react-focus-lock/tree/master)
[](https://www.npmjs.com/package/react-focus-lock)
[](https://bundlephobia.com/result?p=react-focus-lock)
[](https://www.npmtrends.com/react-focus-lock)
It is a trap! We got your focus and will not let him out!
- Modal dialogs. You can not leave it with "Tab", ie do a "tab-out".
- Focused tasks. It will aways brings you back, as you can "lock" user inside a component.
- Any any other case, when you have to lock user _intention_ and _focus_, if that's what `a11y` is asking for.
- Including programatic focus management and smart return focus
### Trusted
Trusted by
[Atlassian AtlasKit](https://atlaskit.atlassian.com),
[ReachUI](https://ui.reach.tech/),
[SmoothUI](https://smooth-ui.smooth-code.com/),
[Storybook](https://storybook.js.org/)
and we will do our best to earn your trust too!
# Features
- no keyboard control, everything is done watching a __focus behavior__, not emulating it. Focus-Locks works for all cases including positive tab indexes.
- React __Portals__ support. Even if some data is in outer space - it is [still in lock](https://github.com/theKashey/react-focus-lock/issues/19).
- _Scattered_ locks, or focus lock groups - you can setup different isolated locks, and _tab_ from one to another.
- Controllable isolation level.
- variable size bundle. Uses _sidecar_ to trim UI part down to 1.5kb.
> 💡 __focus__ locks is part of a bigger whole, consider __scroll lock__ and __text-to-speech__ lock
you have to use to really "lock" the user.
Try [react-focus-on](https://github.com/theKashey/react-focus-on) to archive everything above, assembled in the right order.
# How to use
Just wrap something with focus lock, and focus will be `moved inside` on mount.
```js
import FocusLock from 'react-focus-lock';
const JailForAFocus = ({onClose}) => (