主题
usePreferredColorScheme
反应式 prefers-color-scheme 媒体查询。
¥Reactive prefers-color-scheme media query.
示例
用法
¥Usage
js
import { usePreferredColorScheme } from '@vueuse/core'
const preferredColor = usePreferredColorScheme()
组件用法
¥Component Usage
vue
<template>
<UsePreferredColorScheme v-slot="{ colorScheme }">
Preferred Color Scheme: {{ colorScheme }}
</UsePreferredColorScheme>
</template>
类型声明
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>