You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP β†’
Socket
Book a DemoInstallSign in
Socket

@chakra-ui/focus-lock

Package Overview
Dependencies
Maintainers
2
Versions
258
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@chakra-ui/focus-lock

React focus lock for all Chakra components

2.1.0
latest
Source
npmnpm
Version published
Weekly downloads
408K
-0.5%
Maintainers
2
Weekly downloads
Β 
Created

What is @chakra-ui/focus-lock?

@chakra-ui/focus-lock is a utility package for managing focus within a specific part of the DOM. It is particularly useful for creating accessible modal dialogs, popovers, and other components that require focus to be trapped within a certain area.

What are @chakra-ui/focus-lock's main functionalities?

Focus Lock

This feature ensures that focus is trapped within the modal component, preventing users from tabbing out of the modal.

import { FocusLock } from '@chakra-ui/focus-lock';

function Modal() {
  return (
    <FocusLock>
      <div>
        <h1>Modal Title</h1>
        <p>Modal Content</p>
        <button>Close</button>
      </div>
    </FocusLock>
  );
}

Auto Focus

This feature automatically focuses the first focusable element within the FocusLock component when it is rendered.

import { FocusLock } from '@chakra-ui/focus-lock';

function Modal() {
  return (
    <FocusLock autoFocus>
      <div>
        <h1>Modal Title</h1>
        <p>Modal Content</p>
        <button>Close</button>
      </div>
    </FocusLock>
  );
}

Persistent Focus

This feature ensures that focus remains within the FocusLock component even if the user tries to click outside of it.

import { FocusLock } from '@chakra-ui/focus-lock';

function Modal() {
  return (
    <FocusLock persistentFocus>
      <div>
        <h1>Modal Title</h1>
        <p>Modal Content</p>
        <button>Close</button>
      </div>
    </FocusLock>
  );
}

Other packages similar to @chakra-ui/focus-lock

Keywords

react focus lock

FAQs

Package last updated on 18 Jul 2023

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