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

react-focus-trap

Package Overview
Dependencies
Maintainers
1
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-focus-trap

[![NPM](https://nodei.co/npm/react-focus-trap.png?compact=true)](https://npmjs.org/package/react-focus-trap)

  • 0.6.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
7.9K
decreased by-7.67%
Maintainers
1
Weekly downloads
 
Created
Source

NPM


Build Status Coverage Status


A generic focus management tool for components such as dialogs and dropdowns.

Usage

React Focus Trap is a container element that will manage focus for its children.

let Modal = React.createClass({
  render() {
    return (
      <FocusTrap onExit={ this._onExit } active={ this.props.active }>
        Amazing stuff goes here
      </FocusTrap>
    )
  }
})

When Focus Trap is active, it will do several things:

  1. Ensure focus remains on its content
  2. Exits when clicks outside of the container occur
  3. Exists when the escape key is pressed

Props

NameDefaultDescription
activefalseShould the FocusTrap render?
className'focus-trap-inner'The class of the inner container that maintains focus
onExitnull (but required)Callback when escape or an outside click occurs
element'div'The tag name of the inner container
role'dialog'The aria role for the inner container

Keywords

FAQs

Package last updated on 29 Apr 2015

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