{"id":13445820,"url":"https://github.com/vigetlabs/react-focus-trap","last_synced_at":"2025-04-13T04:09:23.480Z","repository":{"id":24526917,"uuid":"27933122","full_name":"vigetlabs/react-focus-trap","owner":"vigetlabs","description":"Traps focus for accessible dropdowns and modal content","archived":false,"fork":false,"pushed_at":"2022-05-23T14:45:22.000Z","size":523,"stargazers_count":81,"open_issues_count":9,"forks_count":11,"subscribers_count":31,"default_branch":"master","last_synced_at":"2025-04-13T04:09:17.256Z","etag":null,"topics":["a11y","dropdowns","modals","react"],"latest_commit_sha":null,"homepage":"https://react-focus-trap.netlify.com","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vigetlabs.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-12-12T18:39:15.000Z","updated_at":"2024-09-16T05:58:28.000Z","dependencies_parsed_at":"2022-08-22T23:40:47.476Z","dependency_job_id":null,"html_url":"https://github.com/vigetlabs/react-focus-trap","commit_stats":null,"previous_names":[],"tags_count":34,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vigetlabs%2Freact-focus-trap","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vigetlabs%2Freact-focus-trap/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vigetlabs%2Freact-focus-trap/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vigetlabs%2Freact-focus-trap/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vigetlabs","download_url":"https://codeload.github.com/vigetlabs/react-focus-trap/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248661704,"owners_count":21141450,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["a11y","dropdowns","modals","react"],"created_at":"2024-07-31T05:00:40.116Z","updated_at":"2025-04-13T04:09:23.455Z","avatar_url":"https://github.com/vigetlabs.png","language":"JavaScript","funding_links":[],"categories":["Utilities"],"sub_categories":["WIP/Need Awesomeification"],"readme":"[![NPM](https://nodei.co/npm/react-focus-trap.png?compact=true)](https://npmjs.org/package/react-focus-trap)\n\n---\n\n[![Circle CI](https://circleci.com/gh/vigetlabs/react-focus-trap.svg?style=svg)](https://circleci.com/gh/vigetlabs/react-focus-trap)\n\n---\n\nA generic focus management tool for components such as dialogs and dropdowns.\n\n![focus](https://cloud.githubusercontent.com/assets/590904/7422697/c648ecae-ef5c-11e4-8570-5bcf6819f53d.gif)\n\n## Usage\n\nReact Focus Trap is a container element that will manage focus for its children.\n\n```javascript\nlet Modal = React.createClass({\n  render() {\n    return (\n      \u003cFocusTrap onExit={ this._onExit } active={ this.props.active }\u003e\n        Amazing stuff goes here\n      \u003c/FocusTrap\u003e\n    )\n  }\n})\n```\n\nWhen Focus Trap is active, it will do several things:\n\n1. Ensure focus remains on its content\n2. Exits when clicks outside of the container occur\n3. Exits when the escape key is pressed\n\n## Props\n\n| Name       | Default               | Description                                           |\n| ---------- | --------------------- | ----------------------------------------------------- |\n| active     | `true`                | Should the FocusTrap render?                          |\n| className  | `'focus-trap'`         | The class of the inner container that maintains focus |\n| onExit     | `null`                | Callback when escape or an outside click occurs       |\n| element    | `'div'`               | The tag name of the inner container                   |\n| role       | `'dialog'`            | The aria role for the inner container                 |\n\n***\n\n\u003ca href=\"http://code.viget.com\"\u003e\n  \u003cimg src=\"http://code.viget.com/github-banner.png\" alt=\"Code At Viget\"\u003e\n\u003c/a\u003e\n\nVisit [code.viget.com](http://code.viget.com) to see more projects from [Viget.](https://viget.com)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvigetlabs%2Freact-focus-trap","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvigetlabs%2Freact-focus-trap","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvigetlabs%2Freact-focus-trap/lists"}