# use-breakpoint **Repository Path**: mirrors_akheron/use-breakpoint ## Basic Information - **Project Name**: use-breakpoint - **Description**: A React hook for getting the current responsive media breakpoint - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2020-09-24 - **Last Updated**: 2026-05-09 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # use-breakpoint [](https://github.com/iiroj/use-breakpoint/actions) [](https://www.npmjs.com/package/use-breakpoint) [](https://github.com/iiroj/use-breakpoint) [](https://github.com/iiroj/use-breakpoint/blob/master/package.json) [](https://github.com/iiroj/use-breakpoint/blob/master/package.json) A React hook (>=16.8) for getting the current responsive media breakpoint, successor to [breakpoint-observer](https://www.npmjs.com/package/breakpoint-observer). ## Usage Initialize `useBreakpoint` with a configuration object, and optionally a default breakpoint name (in non-window environments like SSR). The return value will be an object with the breakpoint's name (`string`), min-width, and max-width values (`number`): ```javascript import useBreakpoint from 'use-breakpoint'; ... const CurrentBreakpoint = () => { const { breakpoint, maxWidth, minWidth } = useBreakpoint( { mobile: 0, tablet: 768, desktop: 1280 }, 'desktop' ); return (
The current breakpoint is {breakpoint}!
); }; ``` ## Functionality This component uses the [window.matchMedia](https://developer.mozilla.org/en-US/docs/Web/API/Window/matchMedia) functionality to calculate the current breakpoint. For a list of breakpoints, we generate some css media queries in the form of `(min-width: XXXpx) and (max-width: YYYpx)` and then add listeners for the changes. `useBreakpoint` will then update its return value when the breakpoint changes from one rule to another. ## Developing This project is built with [Typescript](http://www.typescriptlang.org/). A [Storybook](http://storybook.js.org/) is included for local previewing. The easiest way to get started is cloning the repo and starting the storybook server locally via `npm start`.