vue-switch-theme
TypeScript icon, indicating that this package has built-in type declarations

0.0.1 • Public • Published

vue-switch-theme

A simple, tiny vue component(or hook) to help you easily implement dark mode.

gitHub license

English | 简体中文

Installation

# npm
npm i @guolao/vue-switch-theme

# yarn
yarn add @guolao/vue-switch-theme

# pnpm
pnpm add @guolao/vue-switch-theme

Usage

<template>
  <SwitchTheme />
</template>

<script setup>
import SwitchTheme from '@guolao/vue-switch-theme'
</script>

Props & Events

Name Type Default Description
mode 'auto' | 'dark' | 'light' 'auto' appearance theme
onChange (theme: 'auto' | 'dark' | 'light') => void null emit after theme mode change

hooks

Customize your own theme switch component by useTheme hook.

<template>
  <button 
    class="theme-button"
    @click="toggle">
    mode: {{ theme }}
  </button>
</template>

<script setup>
import { onMounted } from 'vue'
import { useTheme } from '@guolao/vue-switch-theme'

const { toggle, setTheme, theme } = useTheme('theme-button')
onMounted(() => setTheme('dark'))
</script>

License

MIT

Readme

Keywords

Package Sidebar

Install

npm i vue-switch-theme

Weekly Downloads

1

Version

0.0.1

License

MIT

Unpacked Size

22.6 kB

Total Files

12

Last publish

Collaborators

  • guolao