# use-responsive-react

> React hook for responsive design

Latest version **1.0.1** (published 2021-03-25) · MIT license · 0 weekly downloads

## Install

```sh
npm install use-responsive-react
pnpm add use-responsive-react
yarn add use-responsive-react
bun add use-responsive-react
```

## Health

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

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2021-03-25 |
| First published | 2021-03-25 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Node | >=10 |
| Dependencies | 0 |
| Unpacked size | 16.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | maximegouin |
| Maintainers | maximegouin |

## Links

- npm: https://www.npmjs.com/package/use-responsive-react
- Repository: https://github.com/maximegouin/use-responsive-react
- Homepage: https://github.com/maximegouin/use-responsive-react#readme
- Issues: https://github.com/maximegouin/use-responsive-react/issues
- npm.io page: https://npm.io/package/use-responsive-react

## Recent versions

- 1.0.1 (latest) — 2021-03-25
- 1.0.0 — 2021-03-25

## README

# use-responsive-react

> React hook for responsive design

[![NPM](https://img.shields.io/npm/v/use-responsive-react.svg)](https://www.npmjs.com/package/use-responsive-react) [![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)

## Install

```bash
npm install --save use-responsive-react
```
```bash
yarn add use-responsive-react
```

## Usage

```jsx
import { useResponsive } from 'use-responsive-react'

const Example = () => {
    const { width, screenSize } = useResponsive

    return (
        <div>
            <h1>Render responsive</h1>
            // Get screenSize
            {screenSize === 'md'
                ? <MdComponent />
                : <LgComponent />
            }
            // Get Width
            {width < 800
                ? <MdComponent />
                : <LgComponent />
            }
        </div>
    )
}
```

## Documentation
| Props             | Type   | Desription                     |
|-------------------|--------|--------------------------------|
| width             | Int    | Screen width                   |
| height            | Int    | Screen height                  |
| orientation       | String | Screen orientation             |
| screenSize        | String | Largest screen size            |
| screenSizes       | Array  | All screen sizes               |
| defineBreakpoints | Func   | Define your custom breakpoints |
| breakpoints       | Shape  | Defined breakpoints            |

## Define your own breakpoints
```jsx
import { useResponsive } from 'use-responsive-react'

const Example = () => {
    const { defineBreakpoints } = useResponsive
    
    defineBreakpoints({
        xs: 0,
        sm: 600,
        md: 960,
        lg: 1280,
        xl: 1920
    })
}
```
## License

MIT © [maximegouin](https://github.com/maximegouin)

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