1.0.2 • Published 1 month ago

svelte-dark-mode-toggle v1.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
1 month ago

svelte-dark-mode-toggle

NPM

SvelteJS component for toggling dark mode. There's just a button with cute animation without dark mode logic realization.

Dark mode toggle transition

Demo

REPL Link

Installation

npm install svelte-dark-mode-toggle

Or with Yarn

yarn add svelte-dark-mode-toggle

Usage

<script>
  import DarkModeToggle from 'svelte-dark-mode-toggle'

  let darkMode = false
</script>

<h1>The simpliest usage</h1>
<DarkModeToggle {darkMode} on:click={() => darkMode = !darkMode}/>

API

Props

NameTypeDefault ValueDescription
darkModebooleanCurrent mode state
sizestring28pxSize of component (passed to svg)
titlestringToggle dark modeHint on hover (passed to button)
lightModeColorstring#000000Color of sun
lightModeHoverstring#292828Color of sun of hover
darkModeColorstring#FFFFFFColor of the moon.
darkModeHoverstring#e6e6e6Color of the moon on hover
animationDurationstring.25stransition-duration value
animationDelaystring.25stransition-delay value for moon transformation

Events

Event NameDescription
clickClassic click event

License

MIT

Show your support

Give a ⭐️ if this project helped you!

1.0.2

1 month ago

1.0.1

1 month ago

0.0.1

9 months ago

1.0.0

9 months ago

0.0.3

9 months ago

0.0.2

9 months ago

0.0.5

9 months ago

0.0.4

9 months ago

0.0.6

9 months ago

0.0.0

3 years ago