usePreferredColorScheme ​
Reactive prefers-color-scheme media query.
Demo ​
Usage ​
js
import { usePreferredColorScheme } from '@vueuse/core'
const preferredColor = usePreferredColorScheme()
Component Usage ​
This function also provides a renderless component version via the
@vueuse/components
package. Learn more about the usage.
vue
<template>
<UsePreferredColorScheme v-slot="{ colorScheme }">
Preferred Color Scheme: {{ colorScheme }}
</UsePreferredColorScheme>
</template>
Type Declarations ​
typescript
export type ColorSchemeType = "dark" | "light" | "no-preference"
/**
* Reactive prefers-color-scheme media query.
*
* @see https://vueuse.org/usePreferredColorScheme
* @param [options]
*/
export declare function usePreferredColorScheme(
options?: ConfigurableWindow,
): ComputedRef<ColorSchemeType>
Source ​
Contributors ​
Anthony Fu
Anthony Fu
丶远方
vaakian X
wheat
Alex Kozack
Le Minh Tri
Antério Vieira