Skip to content

usePreferredDark

Category
Export Size
536 B
Last Changed
15 minutes ago
Related

响应式的深色主题偏好。

Demo

喜欢深色:
false

用法

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

const isDark = usePreferredDark()

组件使用

vue
<template>
  <UsePreferredDark v-slot="{ prefersDark }">
    首选深色主题: {{ prefersDark }}
  </UsePreferredDark>
</template>

类型声明

typescript
/**
 * 响应式深色主题偏好。
 *
 * @see https://vueuse.org/usePreferredDark
 * @param [options]
 */
export declare function usePreferredDark(
  options?: ConfigurableWindow,
): Ref<boolean, boolean>

Source

SourceDemoDocs

贡献者

Anthony Fu
丶远方
Anthony Fu
vaakian X
wheat
Alex Kozack
Antério Vieira

变更日志

v9.11.0 on 1/17/2023
d5321 - fix(components): mark defineComponent as pure (#2623)

Released under the MIT License.