Swirski UI

Hook

useMediaQuery

Tracks a CSS media query in React state.

Import

import { useMediaQuery } from "@swirski/ui";

Preview

Live render

useMediaQuery

Preview
Responsive state hook

Usage

const isDesktop = useMediaQuery("(min-width: 1024px)");

Props

2 documented
PropTypeDefaultNotes
queryRequiredstring-CSS media query to observe.
initialValuebooleanfalseInitial value before the browser runs the query.

Returns

1 documented
ValueTypeNotes
matchesbooleanWhether the media query currently matches.
Previous: useLocalStorageNext: useReducedMotion