witDark Dark Mode Toggle Component
witDark is a component used for system theme switching, supports switching between light mode and dark mode, providing users with a more personalized interface experience.
Usage Example
vue
<template>
<div>
<el-button @click="toggleDark">Toggle Dark Mode</el-button>
<witDark v-model="isDark" />
</div>
</template>
<script lang="ts" setup>
import { ref } from 'vue'
const isDark = ref(false)
const toggleDark = () => {
isDark.value = !isDark.value
}
</script>API
| Property Name | Type | Default Value | Description |
|---|---|---|---|
modelValue | [Boolean] | false | Controls the dark mode toggle state, supports v-model two-way binding |
Events
| Event Name | Description | Parameters |
|---|---|---|
update:modelValue | Triggered when dark mode toggle state changes | New mode state (Boolean) |
TIP
- Component is used to switch between light mode and dark mode,
truemeans dark mode,falsemeans light mode. - Component will automatically add or remove the
darkclass name for the page to achieve theme switching effect. - Can control the current theme mode through
v-modeltwo-way binding.
