0.0.2 • Published 2 years ago

react-simple-animated-dark-mode-button v0.0.2

Weekly downloads
-
License
-
Repository
-
Last release
2 years ago

React Simple Animated Dark Mode Button

Description

Demo

react-simple-animated-dark-mode-button library offers a customizable and visually appealing button component that seamlessly transitions between dark mode and light mode themes. This button is designed to simplify the integration of icon-based animations, enhancing user experience and interactivity within your React applications.

Installation

You can install the library using npm or yarn:

npm i react-simple-animated-dark-mode-button

# or

yarn add react-simple-animated-dark-mode-button

Usage Example

import { ThemeIconButton } from "react-simple-animated-dark-mode-button";

const Example = () => {
  const [isDarkMode, setIsDarkMode] = React.useState(false);

  return (
    <ThemeIconButton
      isDarkMode={isDarkMode}
      onClick={() => setIsDarkMode((_isDarkMode) => !_isDarkMode)}
      color={{
        // Give your Icon desired color
        light: "#5628EE",
        dark: "rgb(238 177 40)",
      }}
    />
  );
};

Props

NameTypeDefaultDescription
onClickfunctionRequiredFunction to be called when the button is clicked.
isDarkModebooleanRequiredIndicates whether the current theme mode is dark or light.
colorobjectOptionalCustom colors for the icon.

Known Problems

With Chakra UI

If you have problem with missing animation in Chakra UI try

const [isDarkMode, setIsDarkMode] = React.useState(false);
const { toggleColorMode } = useColorMode();

<ThemeIconButton
  onClick={() => {
    toggleColorMode();
    setTimeout(() => {
      setIsDarkMode(!isDarkMode);
    }, 25);
  }}
/>;