# use-width

> NPM package to use width of screen size dynamically for responsive design

Latest version **0.1.1** (published 2021-09-04) · 0 weekly downloads

## Install

```sh
npm install use-width
pnpm add use-width
yarn add use-width
bun add use-width
```

## Health

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

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.1 |
| Published | 2021-09-04 |
| First published | 2021-09-04 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 10 |
| Unpacked size | 2.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Varun Ramnani and Akshit Suri |
| Maintainers | akshitsuri, varunhhhrahul |
| Keywords | width, react, hooks, dynamic width in react, responsive |

## Links

- npm: https://www.npmjs.com/package/use-width
- npm.io page: https://npm.io/package/use-width

## Dependencies (10)

- [react](https://npm.io/package/react.md) ^17.0.2
- [react-dom](https://npm.io/package/react-dom.md) ^17.0.2
- [@babel/cli](https://npm.io/package/@babel/cli.md) ^7.15.4
- [web-vitals](https://npm.io/package/web-vitals.md) ^1.0.1
- [react-scripts](https://npm.io/package/react-scripts.md) 4.0.3
- [@babel/polyfill](https://npm.io/package/@babel/polyfill.md) ^7.12.1
- [@babel/preset-env](https://npm.io/package/@babel/preset-env.md) ^7.15.4
- [@testing-library/react](https://npm.io/package/@testing-library/react.md) ^11.1.0
- [@testing-library/jest-dom](https://npm.io/package/@testing-library/jest-dom.md) ^5.11.4
- [@testing-library/user-event](https://npm.io/package/@testing-library/user-event.md) ^12.1.10

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

- 0.1.1 (latest) — 2021-09-04
- 0.1.0 — 2021-09-04

## README

# use-width

`NPM package to use width of screen size dynamically for responsive design`

## Import

```
import useWidth from 'use-width';
```

## Usage

```
const [width] = useWidth();
```

```
const component = width > 600 ? <DestopComponent> : <PhoneComponent>;

or

<div style={{ fontSize: width > 600 ? "2rem" : "1rem" }}/>
```

`Width is in pixels.`

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