Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@radix-ui/react-focus-scope

Package Overview
Dependencies
Maintainers
8
Versions
175
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@radix-ui/react-focus-scope

  • 0.1.4-rc.6
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
6.6M
decreased by-3.39%
Maintainers
8
Weekly downloads
 
Created

What is @radix-ui/react-focus-scope?

The @radix-ui/react-focus-scope package is designed to manage focus for UI components, ensuring that keyboard navigation is contained within a specific part of the application. This is particularly useful for modal dialogs, menus, and other components that require focused interaction. It helps in creating accessible and user-friendly interfaces by managing focus order and trapping focus within a specific DOM element.

What are @radix-ui/react-focus-scope's main functionalities?

Focus Trapping

This feature traps focus within the elements wrapped by <FocusScope>. The 'loop' prop allows focus to cycle through the elements inside the scope instead of escaping to elements outside.

import { FocusScope } from '@radix-ui/react-focus-scope';

function App() {
  return (
    <FocusScope loop>
      <div>
        <input />
        <input />
        <button>Click me</button>
      </div>
    </FocusScope>
  );
}

Auto Focus

Automatically focuses the first focusable element within the <FocusScope> when the component mounts. This is useful for directing user attention to a specific part of the application, such as opening a modal dialog.

import { FocusScope } from '@radix-ui/react-focus-scope';

function Dialog() {
  return (
    <FocusScope autoFocus>
      <div tabIndex={-1}>
        <h2>Dialog Title</h2>
        <p>Some content inside the dialog.</p>
        <button>Close</button>
      </div>
    </FocusScope>
  );
}

Other packages similar to @radix-ui/react-focus-scope

FAQs

Package last updated on 20 Jan 2022

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

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc