useBreakpointValue
useBreakpointValue
is a custom hook which returns the value for the current
breakpoint from the provided responsive values object. This hook also responds
to the window resizing and returning the appropriate value for the new window
size.
Import
import { useBreakpointValue } from '@hover/blueprint';
Return value
The useBreakpointValue
hook returns the value for the current breakpoint.
Usage
useBreakpoint
The useBreakpoint
hook simply returns the current responsive breakpoint token.
Server-Side Rendering (SSR)
These hooks are built to work in server-side rendering (SSR) applications by default. You might notice a quick flash of incorrect media query values when you use them.
If you're creating a client-side rendered app, you can leverage the ssr
argument to get the correct value on the first render.
const buttonSize = useBreakpointValue( { base: 'small', tablet: 'medium' }, { ssr: false },);const breakpoint = useBreakpoint({ ssr: false });