You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 7-8.RSVP
Socket
Socket
Sign inDemoInstall

@chakra-ui/focus-lock

Package Overview
Dependencies
Maintainers
3
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


Version published
Weekly downloads
534K
increased by1.91%
Maintainers
3
Created
Weekly downloads
 

Package description

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

Readme

Source

Focus Lock

A React component that traps focus within an element. It is useful for modal dialogs and popovers.

Keywords

FAQs

Package last updated on 16 Jan 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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc