react-light-dark-toggle
TypeScript icon, indicating that this package has built-in type declarations

1.1.0 • Public • Published

React Light Dark Toggle

Build Status Maintainability Test Coverage License: MIT

A customizable React switch for changing between light and dark mode.

Examples

Regular

RegularExample

Styled Like the Google Fonts Toggle

GoogleFontExample

Install

npm i react-light-dark-toggle

Usage and Demo

Visit The Storybook Page

Documentation

Component Props

Property PropType Required Default Description
sunIconComponent `` () => <img src={SunIconSrc} alt="light" /> The component representing the light mode (sun) icon
moonIconComponent `` () => <img src={MoonIconSrc} alt="dark" /> The component representing the dark mode (moon) icon
showSunTransform `` 'translateY(0) translateX(-1em)' The transform to apply when showing the sun icon
hideSunTransform `` 'translateY(4em) translateX(-1em)' The transform to apply when hiding the sun icon
showMoonTransform `` 'translateY(0) translateX(1em)' The transform to apply when showing the moon icon
hideMoonTransform `` 'translateY(-4em) translateX(1em)' The transform to apply when hiding the moon icon
showSunFilter `` '' The filter to apply when showing the sun icon
hideSunFilter `` '' The filter to apply when hiding the sun icon
showMoonFilter `` '' The filter to apply when showing the moon icon
hideMoonFilter `` '' The filter to apply when hiding the moon icon
transitionDuration `` '750ms' How long transitions should take (in ms)
onToggle `` The action to apply on clicking the toggle
darkBorderColor `` 'grey'
lightBorderColor `` 'lightgrey'
darkBackgroundColor `` '#222222'
lightBackgroundColor `` '#EEEEEE'

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.1.0
    1
    • latest

Version History

Package Sidebar

Install

npm i react-light-dark-toggle

Weekly Downloads

1

Version

1.1.0

License

MIT

Unpacked Size

784 kB

Total Files

12

Last publish

Collaborators

  • trickl