useBreakpoint
API
import useBreakpoint from '@restart/hooks/useBreakpoint'
useBreakpoint
(breakpointMap: BreakpointMap<TKey>) => booleanMatch a set of breakpoints
const MidSizeOnly = () => {const isMid = useBreakpoint({ lg: 'down', sm: 'up' });if (isMid) return <div>On a Reasonable sized Screen!</div>return null;}Parameters
breakpointMap
BreakpointMap<TKey>An object map of breakpoints and directions, queries are constructed using "and" to join breakpoints together
Return Value
booleanuseBreakpoint
(breakpoint: TKey, direction?: BreakpointDirection) => booleanMatch a single breakpoint exactly, up, or down.
const PhoneOnly = () => {const isSmall = useBreakpoint('sm', 'down');if (isSmall) return <div>On a Small Screen!</div>return null;}Parameters
breakpoint
TKeyThe breakpoint key
direction?
BreakpointDirectionA direction 'up' for a max, 'down' for min, true to match only the breakpoint
Return Value
boolean