use-media-query
Subscribes to media queries with window.matchMedia
Import
Source
Docs
Package
Usage
use-media-query
subscribes to media queries.
It receives a media query as an argument and returns true
if the given media query matches the current state.
The hook relies on window.matchMedia()
API
and will return false
if the API is not available, unless an initial value is provided in the second argument.
Resize browser window to trigger window.matchMedia
event:
Breakpoint does not match
Server Side Rendering
During server side rendering the hook will always return false
as window.matchMedia
api is not available,
if that is not a desired behavior, you can override the initial value:
UseMediaQueryOptions type
@mantine/hooks
package exports UseMediaQueryOptions
type – a type of the second argument of useMediaQuery
hook.