use-media-query
Subscribes to media queries with window.matchMedia
Source
Docs
PackageIcon
Usage
The use-media-query hook 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 the window.matchMedia() API
and will return false if the API is not available, unless an initial value is provided in the second argument.
Resize the browser window to trigger the window.matchMedia event:
Breakpoint does not match
Server-Side Rendering
During server-side rendering, the hook will always return false as the window.matchMedia API is not available.
If that is not the desired behavior, you can override the initial value:
Definition
Exported types
UseMediaQueryOptions type is exported from @mantine/hooks package,
you can import it in your application: