# @utilityjs/use-get-scrollbar-width

> A React hook that calculates the width of the user agent's scrollbar.

Latest version **1.0.1** (published 2021-10-03) · MIT license · 0 weekly downloads

## Install

```sh
npm install @utilityjs/use-get-scrollbar-width
pnpm add @utilityjs/use-get-scrollbar-width
yarn add @utilityjs/use-get-scrollbar-width
bun add @utilityjs/use-get-scrollbar-width
```

## Health

**Score 35/100 (D)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2021-10-03 |
| First published | 2021-09-18 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 5.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 27 |
| Maintainers | mimshins |
| Keywords | javascript, typescript, react, react hook, scrollbar width, scrollbar size, use scrollbar width, use scrollbar size |

## Links

- npm: https://www.npmjs.com/package/@utilityjs/use-get-scrollbar-width
- Repository: https://github.com/mimshins/utilityjs
- Homepage: https://github.com/mimshins/utilityjs/tree/main/src/hook/useGetScrollbarWidth
- Issues: https://github.com/mimshins/utilityjs/issues
- npm.io page: https://npm.io/package/@utilityjs/use-get-scrollbar-width

## 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

- 1.0.1 (latest) — 2021-10-03
- 1.0.0 — 2021-09-18

## README

<div align="center">
  <h1 align="center">
    useGetScrollbarWidth
  </h1>
</div>

<div align="center">

A React hook that calculates the width of the user agent's scrollbar.

[![license](https://img.shields.io/github/license/mimshins/utilityjs?color=212121&style=for-the-badge)](https://github.com/mimshins/utilityjs/blob/main/LICENSE)
[![npm latest package](https://img.shields.io/npm/v/@utilityjs/use-get-scrollbar-width?color=212121&style=for-the-badge)](https://www.npmjs.com/package/@utilityjs/use-get-scrollbar-width)
[![npm downloads](https://img.shields.io/npm/dm/@utilityjs/use-get-scrollbar-width?color=212121&style=for-the-badge)](https://www.npmjs.com/package/@utilityjs/use-get-scrollbar-width)
[![types](https://img.shields.io/npm/types/@utilityjs/use-get-scrollbar-width?color=212121&style=for-the-badge)](https://www.npmjs.com/package/@utilityjs/use-get-scrollbar-width)

```bash
npm i @utilityjs/use-get-scrollbar-width | yarn add @utilityjs/use-get-scrollbar-width
```

</div>

<hr>

## Usage

```tsx
const App: React.FC = () => {
  const getScrollbarWidth = useGetScrollbarWidth();

  return (
    <div className="app">
      <button onClick={() => void console.log(getScrollbarWidth())}>Log Scrollbar Width</button>
    </div>
  );
};
```

## API

### `useGetScrollbarWidth()`

```ts
declare const useGetScrollbarWidth: (): (() => number);
```

---
_Source: https://npm.io/package/@utilityjs/use-get-scrollbar-width · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
