matchesMedia
Whether the document currently matches a CSS media query.
Outside a browser (no matchMedia, e.g. during server-side rendering), it returns false.
Available since v3.1.5
Import
Section titled “Import”Signature
Section titled “Signature”Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
query | string | A media query, e.g. `‘(min-width: 600px)‘` |
Returns
Section titled “Returns”boolean — true if the query matches now
Examples
Section titled “Examples”Read a media query
Section titled “Read a media query”Returns whether the document matches the query right now.
Safe during server-side rendering
Section titled “Safe during server-side rendering”Without matchMedia (Node.js, a build step), it returns false instead of throwing.
