🚨 Active Supply Chain Attack:node-ipc Package Compromised.Learn More →
Socket
Book a DemoSign in
Socket

react-dark-mode-toggle-2

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-dark-mode-toggle-2

An updated, cute dark mode toggle button for React.

latest
Source
npmnpm
Version
2.1.1
Version published
Weekly downloads
130
-37.8%
Maintainers
1
Weekly downloads
 
Created
Source

react-dark-mode-toggle-2

react code language: typescript latest release bundle size

A cute dark mode toggle 🦉

đź—ť Key features

  • Small bundle size bundle size
  • Written in TypeScript
  • React 18 support
  • ESM support
  • SSR support

🚀 Installation

yarn add react-dark-mode-toggle-2

or

npm install react-dark-mode-toggle-2 --save

or

pnpm add react-dark-mode-toggle-2

✨ Usage

import React from "react";
import { DarkModeToggle } from "react-dark-mode-toggle-2";

export const YourComponent = () => {
  const [isDarkMode, setIsDarkMode] = React.useState(false);
  
  return (
    <DarkModeToggle
      isDarkMode={isDarkMode}
      onChange={setIsDarkMode}
    />
  );
};

📌 Props

PropTypeDefaultRequired
attributesoptional object containing attributes to spread onto the button
isDarkModebooleanN/AYes
onChangefunction that recieves a single argument: the new value of isDarkModeN/AYes
sizenumber (defaults to px) or a string containing a number+unit (e.g "10px", "2em", "4.5rem", "100%", etc). These units may also have a space between them (e.g. "10 px", "2 em", etc).85pxNo
speednumber1.3No
classNamestring''No
idstring''No

Note, this is not a dark mode theme implementation; it's just a button! You'll need to mix this with a management solution such as use-dark-mode.

📝 Notes

In Chrome, you may experience a blue outline around the toggle button after clicking it. If this behavior concerns you see this issue for more information and available workarounds.

🤝 Original Work

Original library react-dark-mode-toggle was created by Alex Thoma. Credit to them and the community for the original work.

✌️ License

MIT

Keywords

react

FAQs

Package last updated on 08 Nov 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts