npm.io
1.0.1 • Published 5 years ago

@utilityjs/use-get-scrollbar-width

Licence
MIT
Version
1.0.1
Deps
0
Size
5 kB
Vulns
0
Weekly
0
Stars
27

useGetScrollbarWidth

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

license npm latest package npm downloads types

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

Usage

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

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

API

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

Keywords