# widths

> return class name base on window inner width

Latest version **0.0.7** (published 2020-02-07) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install widths
pnpm add widths
yarn add widths
bun add widths
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 0.0.7 |
| Published | 2020-02-07 |
| First published | 2019-11-26 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 4.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Maintainers | tylim |
| Keywords | breakpoint, width, css, class, className |

## Links

- npm: https://www.npmjs.com/package/widths
- Repository: https://github.com/tylim88/widths
- Homepage: https://github.com/tylim88/widths#readme
- Issues: https://github.com/tylim88/widths/issues
- npm.io page: https://npm.io/package/widths

## Dependencies (1)

- [clsx](https://npm.io/package/clsx.md) ^1.1.0

## Alternatives

- [style-dictionary](https://npm.io/package/style-dictionary.md) — 2.0M weekly downloads
- [postcss-merge-idents](https://npm.io/package/postcss-merge-idents.md) — 1.7M weekly downloads
- [@fontsource/noto-sans](https://npm.io/package/@fontsource/noto-sans.md) — 93.0K weekly downloads
- [uglifycss](https://npm.io/package/uglifycss.md) — 71.6K weekly downloads
- [mat4-interpolate](https://npm.io/package/mat4-interpolate.md) — 23.3K weekly downloads

## Recent versions

- 0.0.7 (latest) — 2020-02-07
- 0.0.6 — 2020-02-07
- 0.0.5 — 2019-12-10
- 0.0.4 — 2019-11-27
- 0.0.3 — 2019-11-27
- 0.0.2 — 2019-11-26
- 0.0.1 — 2019-11-26
- 0.0.0 — 2019-11-26

## README

# widths

return class name based on window inner width

## ⚠️ Something that is 10 times better...

If you are using [Styled Components](https://www.npmjs.com/package/styled-components), please take a look at [Styled Break](https://www.npmjs.com/package/styled-break), which offer much more powerful and flexible utilities with elegant APIs.

## Installation

```bash
npm i widths
```

## Usage

```js
import widths from 'widths'

widths({ 576:"font-size-small", 768:"font-size-medium", 992:"font-size-big" },window.innerWidth)

// return font-size-small if inner width is less than 576px (not including 576)
// return font-size-medium if inner width is less than 786px (not including 786)
// return font-size-big if inner width is less than 992px (not including 992)
// if width is bigger than all the breakpoints, automatically choose the largest breakpoint class name, eg if inner width is 1200px, return font-size-big

```

## API

```js
widths({ point1:className1...[, pointN:classNameN ]}[,screenWidth])
```

**1. point:**  

breakpoint, must be integer. Return class name if window.innerWidth lower than `point` (not including `point`), lowest breakpoint has highest priority. If window.innerWidth is bigger than all breakpoints, then it automatically return the class of the biggest breakpoint.

**2. className:**

class name to return, use [clsx](https://www.npmjs.com/package/clsx) under the hood, it accepts anything [clsx](https://www.npmjs.com/package/clsx) accepts.

**3. screenWidth:**

source of the width, default is window.innerWidth

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