Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/ryanve/focux

Match :focus-within for better focus experience
https://github.com/ryanve/focux

focus focus-within javascript opensource

Last synced: about 1 month ago
JSON representation

Match :focus-within for better focus experience

Awesome Lists containing this project

README

        

# [`focux`](https://www.npmjs.com/package/focux)
detect [`:focus-within`](https://developer.mozilla.org/en-US/docs/Web/CSS/:focus-within) for better UX

```
npm install focux
```

```js
const focux = require("focux")
```

## api

### `focux.within(element)`

- test if `element` matches `:focus-within` specification
- matches even without native `:focus-within` support
- `element` is a DOM element node
- `@return boolean`

```js
focux.within(element) // true || false
```

## compatibility

- [ES5+](https://caniuse.com/#feat=es5)