Version 0.12.0

useBreakpoint

A hook to detect responsive breakpoints and manage responsive layouts.

Usage#

This hook has performance issues and should be used with caution.

The useBreakpoint hook returns the active breakpoint and two functions, up and down, to check if the viewport is above, or below a given breakpoint, letting you adjust your UI responsively.

Current Breakpoint: initial

The viewport is smaller than 768px.

Breakpoints#

The default breakpoints are:

  • initial: < 640px
  • xs: ≥ 640px < 768px
  • sm: ≥ 768px < 1024px
  • md: ≥ 1024px < 1280px
  • lg: ≥ 1280px < 1536px
  • xl: ≥ 1536px

Return Value#

PropTypeDefaultDescription
breakpoint
"initial""xs""sm""md""lg""xl"
-The current active breakpoint based on screen width
up
(breakpoint: "initial" | "xs" | "sm" | "md" | "lg" | "xl") => boolean
-Function that takes a breakpoint and returns true if the screen width is at or above that breakpoint
down
(breakpoint: "initial" | "xs" | "sm" | "md" | "lg" | "xl") => boolean
-Function that takes a breakpoint and returns true if the screen width is at or below that breakpoint

Changelog#