Skip to content

usePreferredDark

反应式深色主题偏好。

¥Reactive dark theme preference.

示例

Prefers Dark:
false

用法

¥Usage

js
import { usePreferredDark } from '@vueuse/core'

const isDark = usePreferredDark()

组件用法

¥Component Usage

vue
<template>
  <UsePreferredDark v-slot="{ prefersDark }">
    Prefers Dark: {{ prefersDark }}
  </UsePreferredDark>
</template>

类型声明

typescript
/**
 * Reactive dark theme preference.
 *
 * @see https://vueuse.org/usePreferredDark
 * @param [options]
 */
export declare function usePreferredDark(
  options?: ConfigurableWindow,
): Ref<boolean, boolean>

源代码

源代码示例文档

变更日志

No recent changes

VueUse 中文网 - 粤ICP备13048890号