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
import { useMediaQuery } from '@vueuse/core'
const isLargeScreen = useMediaQuery('(min-width: 1024px)')
const isPreferredDark = useMediaQuery('(prefers-color-scheme: dark)')
import { useMediaQuery } from '@vueuse/core'
const isLargeScreen = useMediaQuery('(min-width: 1024px)')
const isPreferredDark = useMediaQuery('(prefers-color-scheme: dark)')
Type Declarations
/**
* Reactive Media Query.
*
* @see https://vueuse.org/useMediaQuery
* @param query
* @param options
*/
export declare function useMediaQuery(
query: string,
options?: ConfigurableWindow
): Ref<boolean>
/**
* Reactive Media Query.
*
* @see https://vueuse.org/useMediaQuery
* @param query
* @param options
*/
export declare function useMediaQuery(
query: string,
options?: ConfigurableWindow
): Ref<boolean>
Source
Contributors
Anthony Fu
Antério Vieira
Dominik Freier
webfansplz
Eureka
karma
Alex Kozack
Jacob Clevenger