react-darkmode-toggler
TypeScript icon, indicating that this package has built-in type declarations

1.2.1 • Public • Published

react-darkmode-toggler

image

Made with create-react-library

NPM JavaScript Style Guide

Demo

Install

npm i react-darkmode-toggler

or

yarn add react-darkmode-toggler

Usage

import React, { useState } from 'react'
 
import { DarkModeToggler } from 'react-darkmode-toggler'
 
const App = () => {
  const [isDark, setIsDark] = useState<'light' | 'dark'>('light')
 
  // button toggler
  const darkModeHandler = () => {
    setIsDark(isDark === 'light' ? 'dark' : 'light')
  }
 
  return (
    <DarkModeToggler
      size='small'
      isDark={isDark}
      onClick={darkModeHandler}
      border='#000'
    />
  )
}

pushpin Props

| Props   | Types               | Default | Required |
| ------- | ------------------- | ------- | -------- |
| isDark  | `light` or `dark`   | 'light' | no       |
| onClick | func                | null    | yes      |
| size    | `middle` or `small` | no      | no       |
| border  | hex color           | #000    | no       |

License

MIT ©

/react-darkmode-toggler/

    Package Sidebar

    Install

    npm i react-darkmode-toggler

    Weekly Downloads

    1

    Version

    1.2.1

    License

    MIT

    Unpacked Size

    11.9 kB

    Total Files

    10

    Last publish

    Collaborators

    • lifeeric