# get-viewport-sizes

> Get correct viewport size and use it in CSS

Latest version **1.0.17** (published 2021-11-20) · ISC license · 0 weekly downloads

## Install

```sh
npm install get-viewport-sizes
pnpm add get-viewport-sizes
yarn add get-viewport-sizes
bun add get-viewport-sizes
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.17 |
| Published | 2021-11-20 |
| First published | 2021-11-20 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 6.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Dave Teu |
| Maintainers | daveteu |

## Links

- npm: https://www.npmjs.com/package/get-viewport-sizes
- npm.io page: https://npm.io/package/get-viewport-sizes

## Recent versions

- 1.0.17 (latest) — 2021-11-20
- 1.0.16 — 2021-11-20
- 1.0.15 — 2021-11-20
- 1.0.14 — 2021-11-20
- 1.0.13 — 2021-11-20
- 1.0.12 — 2021-11-20
- 1.0.11 — 2021-11-20
- 1.0.10 — 2021-11-20
- 1.0.9 — 2021-11-20
- 1.0.8 — 2021-11-20
- 1.0.7 — 2021-11-20
- 1.0.6 — 2021-11-20
- 1.0.5 — 2021-11-20
- 1.0.4 — 2021-11-20
- 1.0.3 — 2021-11-20
- … 3 more at https://npm.io/package/get-viewport-sizes/versions

## README

## Installation
```
npm install get-viewport-sizes
```

To use, call `getSizes()` at the top of your entry file to populate --vh and --vw
```
import { getSizes } from 'get-viewport-sizes';
getSizes(200); // where 200 (default) is the timeout for debounce 
```
You may then use the var in css like this

```
main {
    height: var(--vh * 0.8)  //80% of vh
}
```


## React Hook
You may also use React hook to get the updated with and height

```
const { width, height } = useGetViewportSizes(200) // where 200(default) is the timeout for debounce
```

Hook will return width and height as float

---
_Source: https://npm.io/package/get-viewport-sizes · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
