Skip to content

usePreferredDark ​

Category
Export Size
536 B
Last Changed
2 months ago
Related

Reactive dark theme preference.

Demo ​

Prefers Dark:
false

Usage ​

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

const isDark = usePreferredDark()

Component Usage ​

This function also provides a renderless component version via the @vueuse/components package. Learn more about the usage.

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

Type Declarations ​

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

Source ​

Source • Demo • Docs

Contributors ​

Anthony Fu
Anthony Fu
vaakian X
wheat
Alex Kozack
Antério Vieira

Changelog ​

v12.0.0-beta.1 on 11/21/2024
0a9ed - feat!: drop Vue 2 support, optimize bundles and clean up (#4349)
v9.11.0 on 1/17/2023
d5321 - fix(components): mark defineComponent as pure (#2623)

Released under the MIT License.