# react-use-breakpoints

> A small collection of react hooks that will help you with your responsive designs.

Latest version **0.0.15** (published 2019-03-10) · MIT license · 0 weekly downloads

## Install

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

## 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.0.15 |
| Published | 2019-03-10 |
| First published | 2019-02-22 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 20.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Andrej Jurkin |
| Maintainers | andrejjurkin |
| Keywords | react, hooks, hook, react-use-breakpoints, breakpoints, responsive, breakpoint |

## Links

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

## 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.0.15 (latest) — 2019-03-10
- 0.0.14 — 2019-03-10
- 0.0.13 — 2019-03-10
- 0.0.12 — 2019-02-25
- 0.0.11 — 2019-02-25
- 0.0.10 — 2019-02-22
- 0.0.9 — 2019-02-22
- 0.0.8 — 2019-02-22
- 0.0.7 — 2019-02-22
- 0.0.6 — 2019-02-22
- 0.0.5 — 2019-02-22
- 0.0.4 — 2019-02-22
- 0.0.3 — 2019-02-22

## README

# react-use-breakpoints
### A small collection of react hooks that will help you with your responsive designs.
### Code sample
https://codesandbox.io/s/xjjvnr3yjp?fontsize=14

#### Basic usage
Unless you pass in your own breakpoints, the hook will be using pre-defined (defaultBreakpoints) breakpoints.
```
import { useBreakpoints } from "react-use-breakpoints";

const { breakpoint, windowSize } = useBreakpoints();
```

#### Default breakpoints
```
export const defaultBreakpoints = {
  xs: 0,
  sm: 600,
  md: 960,
  lg: 1280,
  xl: 1920,
};
```

#### Custom breakpoints
It's also possible to define custom breakpoints.
```
import { useBreakpoints } from "react-use-breakpoints";

const customBreakpoints = {
  mobile: 0,
  tablet: 600,
  desktop: 1200
};

const { breakpoint, windowSize } = useBreakpoints(customBreakpoints);
````
You can use `BreakpointContext` to provide your custom breakpoints.
```
import React, { useContext } from "react";
import {
  Breakpoints,
  BreakpointContext,
  useBreakpoints
} from "react-use-breakpoints";

const customBreakpoints = {
  mobile: 0,
  tablet: 600,
  desktop: 1200
};

function App() {
  return (
    <Breakpoints breakpoints={customBreakpoints}>
      <div className="App">
        <CustomBreakpoints />
      </div>
    </Breakpoints>
  );
}

function CustomBreakpoints() {
  const breakpoints = useContext(BreakpointContext);
  const { breakpoint } = useBreakpoints(breakpoints);
  ...
}
```

#### Use WindowSize hook
This hook provides inner and outer window widths as the window is being resized.
```
import { useWindowSize } from "react-use-breakpoints";

const { innerWidth, outerWidth } = useWindowSize();
```

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