GithubHelp home page GithubHelp logo

isabella232 / react-focus-trap Goto Github PK

View Code? Open in Web Editor NEW

This project forked from vigetlabs/react-focus-trap

0.0 0.0 0.0 527 KB

Traps focus for accessible dropdowns and modal content

Home Page: https://react-focus-trap.netlify.com

License: MIT License

HTML 4.69% JavaScript 76.40% CSS 7.31% Makefile 4.41% Shell 7.21%

react-focus-trap's Introduction

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

Name Default Description
active true Should the FocusTrap render?
className 'focus-trap' The class of the inner container that maintains focus
onExit null 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

Code At Viget

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

react-focus-trap's People

Contributors

kyleamathews avatar nhunzaker avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.