Skip to content

usePreferredDark

Category
Export Size
1.21 kB
Last Changed
2 months 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

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

Changelog

v14.0.0-alpha.0 on
8c521 - feat(components)!: refactor components and make them consistent (#4912)
v13.6.0 on
d32f8 - refactor: add @__NO_SIDE_EFFECTS__ annotations to all pure functions (#4907)
v12.0.0-beta.1 on
0a9ed - feat!: drop Vue 2 support, optimize bundles and clean up (#4349)

Released under the MIT License.

Build faster with AI
New Masterclass to help you leverage AI in your Vue workflow
Get Early Access