# @etheryte/focus-group

> `FocusGroup` is a basic building block for constructing accessible menus and interactive UI components that depend on focusable elements.

Latest version **2.1.0** (published 2023-12-07) · UNLICENSED license · 0 weekly downloads

## Install

```sh
npm install @etheryte/focus-group
pnpm add @etheryte/focus-group
yarn add @etheryte/focus-group
bun add @etheryte/focus-group
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.1.0 |
| Published | 2023-12-07 |
| First published | 2022-09-22 |
| Weekly downloads | 0 |
| License | UNLICENSED |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 8.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | etheryte |
| Keywords | react |

## Links

- npm: https://www.npmjs.com/package/@etheryte/focus-group
- npm.io page: https://npm.io/package/@etheryte/focus-group

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 2.1.0 (latest) — 2023-12-07
- 2.0.1 — 2023-11-05
- 2.0.0 — 2023-11-05
- 1.0.5 — 2022-09-30
- 1.0.4 — 2022-09-26
- 1.0.3 — 2022-09-22
- 1.0.1 — 2022-09-22
- 1.0.0 — 2022-09-22

## README

# FocusGroup

`FocusGroup` is a basic building block for constructing accessible menus and interactive UI components that depend on focusable elements.

## Installation

```sh
yarn add @etheryte/focus-group
```

## Props

| Prop | Description | Default value |
|-|-|-|
|`onFocusOut`| Optional, function to be called when the user focus moves outside of the container. | `undefined`|

## Usage

```tsx
import { useState } from "react";
import { FocusGroup } from "@etheryte/focus-group";

const Example = () => {
  const [isMenuOpen, setIsMenuOpen] = useState(false);

  return (
    <FocusGroup onFocusOut={() => setIsMenuOpen(false)}>
      <button
        id="example-button"
        aria-haspopup="menu"
        aria-controls="example-menu"
        aria-expanded={isMenuOpen}
        type="button"
        onClick={() => setIsMenuOpen(!isMenuOpen)}
      >
        Open menu
      </button>
      <menu
        id="example-menu"
        aria-label="Example menu"
        hidden={!isMenuOpen}
      >
        <li>Menu item</li>
      </menu>
    </FocusGroup>
  );
};
```

## Development

Run a development demo:

```sh
yarn start
```

Publish a new version:

```sh
npm login
npm publish --access public
```

---
_Source: https://npm.io/package/@etheryte/focus-group · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
