Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@regrapes/react-breakpoint-hooks

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@regrapes/react-breakpoint-hooks

[![install size](https://packagephobia.com/badge?p=@regrapes/react-breakpoint-hooks@0.1.5)](https://packagephobia.com/result?p=@regrapes/react-breakpoint-hooks@0.1.5)

  • 0.1.7
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
1
decreased by-66.67%
Maintainers
1
Weekly downloads
 
Created
Source

@regrapes/react-breakpoint-hooks

install size

This project is maintained by REGRAPES.

Intention

Creates easy to use breakpoint hooks for react, based on @react-hook/media-query package and inspired by Material UIs breakpoint definitions (can be overwritten).

Install

npm i @regrapes/react-breakpoint-hooks

Example

import { BreakpointProvider } from "@regrapes/react-breakpoint-hooks";

<BreakpointProvider>
  <App />
</BreakpointProvider>;
import { useBreakpoints } from "@regrapes/react-breakpoint-hooks";

function App() {
  const { isScreenMD } = useBreakpoints();

  return (
    <div className="App">
      {isScreenMD.exact && <div>Renders only on exact screen size MD</div>}
      {isScreenMD.up && (
        <div>Renders only on screen size MD and above (LG, XL)</div>
      )}
      {isScreenMD.down && (
        <div>Renders only on screen size MD and below (SM, XS)</div>
      )}
    </div>
  );
}

Default breakpoints

BreakpointSize (px)
XS0
SM600
MD960
LG1280
XL1920

Inspired by Material UIs breakpoints

Options

useBreakpoints() provides...

const { isScreenXS, isScreenSM, isScreenMD, isScreenLG, isScreenXL } = useBreakpoints();

Every options provide exact, up and down property, which return a boolean.

Overwriting breakpoints

You can use your own breakpoints by passing your own breakpoints into the BreakpointProvider:

import { BreakpointProvider } from "@regrapes/react-breakpoint-hooks";

const BREAKPOINTS = {
  XS: 0,
  SM: 600,
  MD: 960,
  LG: 1280,
  XL: 1920,
};

<BreakpointProvider breakpoints={BREAKPOINTS}>
  <App />
</BreakpointProvider>;

LICENSE

MIT

FAQs

Package last updated on 07 Apr 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc