Ensure focus remains within a specified component, enhancing interactions for modals, dialogs, and overlays.
Automatically return focus to a previously focused element after actions like closing a modal or a dialog.
Dynamically manage and adjust the tab order of elements in the UI layout.
Improve keyboard navigation within complex UI components like menus, dropdowns, and lists.
Easily customize focus indicators with various styles and animations to match your design.
Differentiate between keyboard and mouse focus using the :focus-visible state.
Automatically set focus on any element when components mount.
Improve accessibility by announcing focus changes to screen readers.
Built for high performance with a minimal footprint.
To install the React Refocus library, use the following command:
npm install react-refocus
Alternatively, if you use Yarn:
yarn add react-refocus
import { FocusTrap } from 'react-refocus';
const MyComponent = () => (
<FocusTrap>
<div>
<button>Button 1</button>
<button>Button 2</button>
</div>
</FocusTrap>
);
See Documentation for complete API reference.
We welcome contributions from the community to make React Refocus better. If you find any issues or have suggestions for improvements, feel free to contribute or open an issue on our GitHub Repository.
This project is licensed under the MIT License - see the LICENSE file for details.
If you find any issues or have suggestions for improvements, feel free to contribute or open an issue on our GitHub Repository. We welcome contributions from the community to make React Refocus better.