Skip to content
On this page

usePreferredDark

Category
Export Size
1.06 kB
Last Changed
last year
Related

Reactive dark theme preference.

Demo

Prefers Dark:
false

Usage

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

const isDark = usePreferredDark()
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.

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

Type Declarations

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

Source

SourceDemoDocs

Contributors

Anthony Fu
wheat
Alex Kozack
Antério Vieira

Changelog

No recent changes

Released under the MIT License.