Skip to content

A simple component to switch between dark and light themes.

License

Notifications You must be signed in to change notification settings

QVGK/react-toggle-theme

Repository files navigation

React Toggle Theme

Reformed by QVGK

About React Toggle Theme

React Toggle Theme was a React component originally created by forgng.

I saw that it had many issues that weren't getting fixed, so I decided to take it into my own hands and "reform" the module. I took out all packages that weren't needed, and fixed the ones that still remained. Then, I took the original code for the switch and put it here.

Oh, and I had to learn some TypeScript for this. You're welcome.

Installation

yarn add @qvgk/react-toggle-theme
npm install @qvgk/react-toggle-theme

Usage

import React, { useState } from "react"
import ToggleTheme from "@qvgk/react-toggle-theme"

export default function App() {
  const [currentTheme, setCurrentTheme] = useState("light")

  return (
    <div style={{ backgroundColor: currentTheme === "light" ? "#000" : "#fff" }}>
      <ToggleTheme selectedTheme={currentTheme} onChange={setCurrentTheme} />
    </div>
  )
}