usePreferredColorScheme
Reactive prefers-color-scheme media query.
Demo
Usage
js
import { usePreferredColorScheme } from '@vueuse/core'
const preferredColor = usePreferredColorScheme()
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.
html
<UsePreferredColorScheme v-slot="{ colorScheme }">
Preferred Color Scheme: {{ colorScheme }}
<UsePreferredColorScheme>
<UsePreferredColorScheme v-slot="{ colorScheme }">
Preferred Color Scheme: {{ colorScheme }}
<UsePreferredColorScheme>
Type Declarations
typescript
export declare 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>
export declare 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
wheat
Alex Kozack
Le Minh Tri
Antério Vieira