# @zendeskgarden/container-focusvisible

> Containers relating to the :focus-visible polyfill hook in the Garden Design System

Latest version **2.0.7** (published 2025-04-08) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install @zendeskgarden/container-focusvisible
pnpm add @zendeskgarden/container-focusvisible
yarn add @zendeskgarden/container-focusvisible
bun add @zendeskgarden/container-focusvisible
```

## Health

**Score 35/100 (D)** — status: maintenance-mode.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.7 |
| Published | 2025-04-08 |
| First published | 2019-08-09 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 28.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Zendesk Garden <garden@zendesk.com> |
| Maintainers | zendesk-garden |
| Keywords | a11y, accessible, container, garden, headless, react, zendesk |

## Links

- npm: https://www.npmjs.com/package/@zendeskgarden/container-focusvisible
- Repository: https://github.com/zendeskgarden/react-containers
- Homepage: https://garden.zendesk.com/
- Issues: https://github.com/zendeskgarden/react-containers/issues
- npm.io page: https://npm.io/package/@zendeskgarden/container-focusvisible

## Dependencies (1)

- [@babel/runtime](https://npm.io/package/@babel/runtime.md) ^7.8.4

## 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.0.7 (latest) — 2025-04-08
- 2.0.6 — 2024-08-23
- 2.0.5 — 2024-08-12
- 2.0.4 — 2024-07-01
- 2.0.3 — 2024-01-23
- 2.0.2 — 2023-09-28
- 2.0.1 — 2023-07-28
- 2.0.0 — 2023-06-29
- 1.0.6 — 2023-06-12
- 1.0.5 — 2023-04-19
- 1.0.4 — 2023-03-17
- 1.0.2 — 2023-02-17
- 1.0.1 — 2022-10-10
- 1.0.0 — 2022-06-17
- 0.4.10 — 2022-03-31
- … 14 more at https://npm.io/package/@zendeskgarden/container-focusvisible/versions

## README

# @zendeskgarden/container-focusvisible [![npm version][npm version badge]][npm version link]

[npm version badge]: https://flat.badgen.net/npm/v/@zendeskgarden/container-focusvisible
[npm version link]: https://www.npmjs.com/package/@zendeskgarden/container-focusvisible

This package includes containers relating to [the `:focus-visible`
polyfill](https://developer.mozilla.org/en-US/docs/Web/CSS/:focus-visible) in
the [Garden Design System](https://zendeskgarden.github.io/).

## Installation

```sh
npm install @zendeskgarden/container-focusvisible
```

## Usage

Check out [storybook](https://zendeskgarden.github.io/react-containers) for live
examples.

### useFocusVisible

```jsx
import { useRef } from 'react';
import styled from 'styled-components';
import { useFocusVisible } from '@zendeskgarden/container-focusvisible';

const FocusVisibleButton = styled.button`
  :focus {
    outline: none;
  }

  /* Apply custom focus styling based on className */
  &.garden-focus-visible {
    outline: 2px dashed red;
  }

  /* Apply custom focus styling based on data attribute */
  &[data-garden-focus-visible] {
    outline: 2px dashed red;
  }
`;

const Example = () => {
  const scope = useRef();
  useFocusVisible({ scope });

  return (
    <div ref={scope}>
      <FocusVisibleButton>
        This element receives focus-visible className and data attribute
      </FocusVisibleButton>
    </div>
  );
};
```

### FocusVisibleContainer

```jsx
import { FocusVisibleContainer } from '@zendeskgarden/container-focusvisible';

const Example = () => {
  const scope = useRef();

  return (
    <FocusVisibleContainer scope={scope} className="custom-focus-visible-class">
      <div ref={scope}>
        <button>Hello world</button>
        <input placeholder="some elements always receive focus-visible" />
      </div>
    </FocusVisibleContainer>
  );
};
```

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