useMediaQuery ​
Reactive Media Query. Once you've created a MediaQueryList object, you can check the result of the query or receive notifications when the result changes.
Demo ​
isLargeScreen: false
prefersDark: false
Usage ​
js
import { useMediaQuery } from '@vueuse/core'
const isLargeScreen = useMediaQuery('(min-width: 1024px)')
const isPreferredDark = useMediaQuery('(prefers-color-scheme: dark)')
Type Declarations ​
typescript
/**
* Reactive Media Query.
*
* @see https://vueuse.org/useMediaQuery
* @param query
* @param options
*/
export declare function useMediaQuery(
query: MaybeRefOrGetter<string>,
options?: ConfigurableWindow,
): Ref<boolean, boolean>
Source ​
Contributors ​
Anthony Fu
Antério Vieira
Anthony Fu
Indrek Ardel
Zhousg
Young
Jelf
Dominik Freier
webfansplz
Eureka
karma
Alex Kozack
Jacob Clevenger
Changelog ​
v12.0.0-beta.1
on 11/21/2024v10.3.0
on 7/30/2023v10.0.0-beta.4
on 4/13/20234d757
- feat(types)!: rename MaybeComputedRef
to MaybeRefOrGetter
10e98
- feat(toRef)!: rename resolveRef
to toRef
v10.0.0-beta.3
on 4/12/2023v9.3.0
on 9/26/2022