0.2.8 • Published 10 days ago

naive-dark-mode v0.2.8

Weekly downloads
-
License
MIT
Repository
github
Last release
10 days ago

Naïve Dark Mode

Dark Mode for Vue3 and Naive UI.

npm version publish GitHub

Online Demo

Installation

Use your favorite package manager to install:

yarn add naive-dark-mode

Usage

Type

export type NaiveDarkModeType = undefined | 'light' | 'dark' | 'system'

Component API

PropertyTypeDefaultDescription
dark-modeNaiveDarkModeType'system'The dark mode setting.
design-darkstring'#000000'The design color for dark mode.
design-lightstring'#ffffff'The design color for light mode.
fade-layernumber25The number of steps or iterations for the smooth transition to dark mode. <= 0 for no transition.
v-model:colorstring'#ffffff'The transition color value.
v-model:naivethemeanyundefinedThe Naive UI theme.

Example

<script lang="ts" setup>
import { ref, Ref } from 'vue'
import { NConfigProvider, NGlobalStyle } from 'naive-ui'
import { NaiveDarkMode } from 'naive-dark-mode'
import type { NaiveDarkModeType } from 'naive-dark-mode'

const dmode = ref('system' as NaiveDarkModeType)
// v-model child component
const color = ref('')
const naiveTheme: Ref<any> = ref(undefined)

// // Change dark mode
// function handleDarkModeChange(mode: NaiveDarkModeType): void {
//   dmode.value = mode
// }
</script>

<template>
  <n-config-provider :theme="naiveTheme">
    <n-global-style />
    <naive-dark-mode
      v-model:color="color"
      v-model:naivetheme="naiveTheme"
      :dark-mode="dmode"
      :fade-layer="20"
      :design-light="'#fcf1f1'"
      :design-dark="'#051f1f'"
      class="naive-dark-mode"
    />
    <my-app />
  </n-config-provider>
</template>

<style lang="scss" scoped>
$global-color: v-bind(color);

.naive-dark-mode {
  box-sizing: border-box;
  position: absolute;
  width: 100%;
  height: 100%;
  background-color: $global-color;
  display: flex;
  flex-direction: column;
}
</style>

License

naive-dark-mode is licensed under the MIT License.

0.2.8

10 days ago

0.2.7

30 days ago

0.2.6

2 months ago

0.2.5

2 months ago

0.2.4

2 months ago

0.2.3

3 months ago

0.2.2

4 months ago

0.2.1

7 months ago

0.2.0

8 months ago

0.1.4

8 months ago

0.1.3

9 months ago

0.1.2

9 months ago

0.1.1

9 months ago

0.1.0

9 months ago

0.0.7

9 months ago

0.0.6

9 months ago

0.0.5

9 months ago

0.0.4

9 months ago

0.0.3

9 months ago

0.0.2

9 months ago

0.0.1

9 months ago