1.1.0 • Published 6 months ago

vue-toggle-theme v1.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
6 months ago

npm GitHub package version NPM Downloads

Install

yarn add vue-toggle-theme

Usage

defaultTheme accepts the values light or dark. If no value is specified, the user's theme will be used.

<template>
  <ToggleTheme :defaultTheme="'light'">
    <svg>...</svg>
  </ToggleTheme>
</template>

<script>
import ToggleTheme from 'vue-toggle-theme'

export default {
  components: {
    ToggleTheme
  }
}
</script>

Add a <meta> element with the theme-color attribute to the <head> section.

<meta name="theme-color" content="">
:root {
  --meta-theme-color: White;
}

[data-theme='dark'] {
  --meta-theme-color: Black;
}

Fix "flash of inaccurate color theme".

<script>
  const e = window.matchMedia("(prefers-color-scheme: dark)").matches
      ? "dark"
      : "light",
    t = localStorage.getItem("theme") || e,
    a = document.documentElement;
  a.setAttribute("data-theme", t), localStorage.setItem("theme", t);
</script>

License

vue-toggle-theme is released under MIT license

1.0.2

6 months ago

1.1.0

6 months ago

1.0.1

7 months ago

1.0.0

7 months ago

0.2.1

9 months ago

0.2.0

9 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.4

10 months ago

0.0.3

10 months ago

0.0.2

10 months ago

0.0.1

10 months ago