# ✨ useDarkMode
The
useDarkMode ()
function is used to return a copy of the filtered object using the givenkey
value. This function provides the desired condition by specifying which properties are selected from the object.
# 🍁 Usage
The example usage of useDarkMode
function is shown below.
import { useDarkMode } from 'vue-composable-utils'; const { darkMode, setDarkMode } = useDarkMode();
Copied!
# 🚀 Features
useDarkMode
takes two parameters.
Parameter | Description |
---|---|
darkMode | The object to be processed. |
setDarkMode | Optional. The key value that should be selected. |
# 💐 Example
You can see how it changes reactively using the example below.
template
javascript
scss
<template> <div> <a @click="setDarkMode((darkMode = !darkMode))"> <p v-if="darkMode">🌞 Light</p> <p v-if="!darkMode">🌜 Dark</p> </a> </div> </template>
Copied!