1.0.18 • Published 3 years ago

react-day-and-night-toggle v1.0.18

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

react-day-and-night-toggle

🌞Day & Night🌛 (light/dark) theme switch with pretty cool animation for React.

Made a React component from Da_Woodhead codepen.

Live demo

A demo is worth a thousand words

Installation

Using npm:

npm install react-day-and-night-toggle

Using yarn:

yarn add react-day-and-night-toggle

Usage

import React, { useState } from 'react'
import DayNightToggle from 'react-day-and-night-toggle'

const App = () => {
  const [isDarkMode, setIsDarkMode] = useState(false)

  return (
    <DayNightToggle
      onChange={() => setIsDarkMode(!isDarkMode)}
      checked={isDarkMode}
    />
  )
}

Props

PropTypeDefaultRequiredDescription
onChangefunctionyesCallback for when the switch is checked, use this to set your state.
checkedbooleanyesThe state of the switch is passed here.
sizenumber32noThe size of the button that corresponds to its height (it is recommended to use an even integer number). The passed number will be automatically rounded down to the lowest integer.
startInactivebooleanfalsenoThe button is disabled for 2 seconds after rendering (this can come in handy when some theme is enabled and your site is loading styles, and you don't want the user to change the theme during this).
animationInactivebooleantruenoThe button is disabled after being pressed during animation (that's 2 seconds).
shadowsbooleantruenoA shadow, dark at "day" mode and light at "night" mode, around the button.
classNamestringundefinednoYour own classnames.

License

MIT © carrymisss

1.0.18

3 years ago

1.0.17

3 years ago

1.0.16

3 years ago

1.0.15

3 years ago

1.0.14

3 years ago

1.0.13

3 years ago

1.0.12

3 years ago

1.0.11

3 years ago

1.0.10

3 years ago

1.0.9

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago