Skip to content

usePreferredDark

Category
Export Size
1.21 kB
Last Changed
4 days ago
Related

Reactive dark theme preference.

Demo

Prefers Dark:
false

Usage

ts
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

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

Source

SourceDemoDocs

Contributors

NoiseFan

Changelog

No recent changes

Released under the MIT License.