Security News
38% of CISOs Fear They’re Not Moving Fast Enough on AI
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
react-scrollbar-size
Advanced tools
React-Scrollbar-Size is a React hook designed to calculate the size of the user agent's horizontal and vertical scrollbars. It will also detect when the size of the scrollbars change, such as when the user agent's zoom factor changes.
React-Scrollbar-Size is available as an npm package:
$ npm install react-scrollbar-size
The useScrollbarSize
custom hook returns an object with two properties:
Name | Description |
---|---|
width | The current width of the vertical scrollbar |
height | The current height of the horizontal scrollbar |
To see a live example, follow these instructions.
import { CSSProperties, FunctionComponent } from 'react';
import useScrollbarSize from 'react-scrollbar-size';
const styles: CSSProperties = {
margin: '1rem',
textAlign: 'center',
};
const ScrollbarSizeDemo: FunctionComponent = () => {
const { height, width } = useScrollbarSize();
return (
<div style={styles}>
<h2>React Scrollbar Size Demo</h2>
<h4>Tip: Change browser zoom level to see scrollbar sizes change.</h4>
<p>
The current height of the scrollbar is {height}px.
<br />
The current width of the scrollbar is {width}px.
</p>
</div>
);
};
import useScrollbarSize from 'react-scrollbar-size';
const styles = {
margin: '1rem',
textAlign: 'center',
};
const ScrollbarSizeDemo = () => {
const { height, width } = useScrollbarSize();
return (
<div style={styles}>
<h2>React Scrollbar Size Demo</h2>
<h4>Tip: Change browser zoom level to see scrollbar sizes change.</h4>
<p>
The current height of the scrollbar is {height}px.
<br />
The current width of the scrollbar is {width}px.
</p>
</div>
);
};
This project is licensed under the terms of the MIT license.
[5.0.0] - 2022-05-07
> 0.5%, last 2 versions, Firefox ESR, not dead
) plus not ie 11
. Browsers outside of that range may be supported, but are not guaranteed. (#705)FAQs
React hook to calculate the size of browser scrollbars
The npm package react-scrollbar-size receives a total of 0 weekly downloads. As such, react-scrollbar-size popularity was classified as not popular.
We found that react-scrollbar-size demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.
Security News
Company News
Socket is joining TC54 to help develop standards for software supply chain security, contributing to the evolution of SBOMs, CycloneDX, and Package URL specifications.