2.7.2 • Published 2 years ago

react-focus-trap v2.7.2

Weekly downloads
2,913
License
MIT
Repository
github
Last release
2 years ago

NPM


Circle CI


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

focus

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. Exits when the escape key is pressed

Props

NameDefaultDescription
activetrueShould the FocusTrap render?
className'focus-trap'The class of the inner container that maintains focus
onExitnullCallback 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

Visit code.viget.com to see more projects from Viget.

2.7.2

2 years ago

2.7.1

6 years ago

2.7.0

6 years ago

2.6.0

6 years ago

2.6.0-beta.0

6 years ago

2.5.0

7 years ago

2.4.0

7 years ago

2.3.3

8 years ago

2.3.2

8 years ago

2.3.1

8 years ago

2.3.0

8 years ago

2.2.0

8 years ago

2.1.0

8 years ago

1.1.2

8 years ago

2.0.0

8 years ago

1.1.1

8 years ago

1.2.0

9 years ago

1.1.0

9 years ago

1.0.3

9 years ago

1.0.2

9 years ago

1.0.1

9 years ago

1.0.0

9 years ago

0.8.0

9 years ago

0.7.0

9 years ago

0.7.0-alpha

9 years ago

0.6.1

9 years ago

0.6.0

9 years ago

0.5.2

9 years ago

0.5.1

9 years ago

0.5.0

9 years ago

0.4.0

9 years ago

0.3.0

9 years ago

0.2.0

9 years ago

0.1.1

9 years ago

0.1.0

9 years ago

0.0.1

9 years ago