React Hook for easy dark mode integration
Go to file
2020-01-06 23:18:38 +01:00
lib initial commit 2020-01-06 23:17:34 +01:00
test initial commit 2020-01-06 23:17:34 +01:00
.gitignore initial commit 2020-01-06 23:17:34 +01:00
.npmignore initial commit 2020-01-06 23:17:34 +01:00
.prettierrc initial commit 2020-01-06 23:17:34 +01:00
LICENSE initial commit 2020-01-06 23:17:34 +01:00
package.json initial commit 2020-01-06 23:17:34 +01:00
README.md Update README.md 2020-01-06 23:18:38 +01:00
tsconfig.json initial commit 2020-01-06 23:17:34 +01:00

use-light-switch

Version Dependencies Size Badge

React hook for dark mode.

🌈 Features

  • Typescript compatible
  • 0 Dependencies
  • Tiny ~0.7kB
  • React Hooks
Installation
npm i use-light-switch

🤔 Motivation

There was no library with typings 🤕

🚀 Quickstart

import React from 'react'
import ReactDOM from 'react-dom'
import { useModeSelector } from 'use-light-switch'

const App: React.FC = () => {
    const selected = useModeSelector({
        light: { color: 'green', name: 'Light' },
        dark: { color: 'red', name: 'Dark' },
        unset: { color: 'blue', name: 'Unset' },
    })

    return <div>
        <h3>Selector</h3>
        <div style={{
            padding: '1em 2em',
            backgroundColor: selected.color
        }}>
            {selected.name}
        </div>
    </div>
}

ReactDOM.render(<App />, window.document.getElementById('root'))