Skip to content
0

katanakit-js / useMatchesMedia

Function: useMatchesMedia() ​

ts
function useMatchesMedia(query): boolean;

Defined in: src/infrastructure/viewport/viewport.service.ts:56

Tests a CSS media query against the current viewport.

Parameters ​

ParameterTypeDescription
querystringA CSS media query string (e.g. "(min-width: 768px)").

Returns ​

boolean

true if the query matches.

Example ​

ts
if (useMatchesMedia("(prefers-reduced-motion: reduce)")) {
  // disable animations
}

Released under the MIT License.