https://github.com/WICG/focus-visible
Polyfill for `:focus-visible`
https://github.com/WICG/focus-visible
Last synced: about 1 month ago
JSON representation
Polyfill for `:focus-visible`
- Host: GitHub
- URL: https://github.com/WICG/focus-visible
- Owner: WICG
- License: other
- Created: 2017-03-08T07:05:18.000Z (about 8 years ago)
- Default Branch: main
- Last Pushed: 2024-08-12T17:08:59.000Z (8 months ago)
- Last Synced: 2024-12-03T09:49:04.170Z (4 months ago)
- Language: JavaScript
- Homepage: https://wicg.github.io/focus-visible/demo/
- Size: 808 KB
- Stars: 1,602
- Watchers: 36
- Forks: 124
- Open Issues: 56
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.md
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
- awesome-github-star - focus-visible - visible` | WICG | 1603 | (JavaScript)
- awesome-list - focus-visible - visible` | WICG | 1430 | (JavaScript)
README
[](https://travis-ci.org/WICG/focus-visible)
Based on the proposed CSS
[`:focus-visible`](https://drafts.csswg.org/selectors-4/#the-focus-visible-pseudo)
pseudo-selector,
this prototype adds a `focus-visible` class to the focused element,
in situations in which the `:focus-visible` pseudo-selector should match.# Details
- Read the [Explainer](explainer.md).
- Read the [Spec](https://drafts.csswg.org/selectors-4/#the-focus-visible-pseudo).
- Try the [Demo](https://wicg.github.io/focus-visible/demo).
- [Give feedback!](https://github.com/WICG/focus-visible/issues)
- Open discussions:
- [What's the impact on users with low vision or cognitive impairments?](https://github.com/WICG/focus-visible/issues/128)
- [Should :focus-visible match when returning focus or programmatically focusing?](https://github.com/WICG/focus-visible/issues/88)
- [Brainstorm: options for opting in to always matching focus ring.](https://github.com/WICG/focus-visible/issues/42)# Polyfill
## Support
👋 `:focus-visible` is now [supported in all major browsers](https://developer.mozilla.org/en-US/docs/Web/CSS/:focus-visible#browser_compatibility).

We would encourage you to use the CSS selector instead of this polyfill if you are able. We are not currently planning to make any updates or release new versions of the polyfill, but are open to discussion in GitHub issues if changes need to be made for emergencies.
## Installation
`npm install --save focus-visible`
_We recommend only using versions of the polyfill that have been published to npm, rather than
cloning the repo and using the source directly. This helps ensure the version you're using is stable
and thoroughly tested.__If you do want to build from source, make sure you clone the latest tag!_
## Usage
### 1. Add the script to your page
```html
...