# dark-mode-toggle-animation

> Sun-moon animation for toggling dark mode

Latest version **1.0.1** (published 2021-02-26) · MIT license · 0 weekly downloads

## Install

```sh
npm install dark-mode-toggle-animation
pnpm add dark-mode-toggle-animation
yarn add dark-mode-toggle-animation
bun add dark-mode-toggle-animation
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2021-02-26 |
| First published | 2021-02-23 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 278.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | noelsner |

## Links

- npm: https://www.npmjs.com/package/dark-mode-toggle-animation
- Repository: https://github.com/noelsner/dark-mode-toggle
- Homepage: https://github.com/noelsner/dark-mode-toggle#readme
- Issues: https://github.com/noelsner/dark-mode-toggle/issues
- npm.io page: https://npm.io/package/dark-mode-toggle-animation

## Recent versions

- 1.0.1 (latest) — 2021-02-26
- 1.0.0 — 2021-02-23

## README

# @noelsner/dark-mode-toggle-animation

Sun-moon animation for toggling dark mode ☀️ ↔ 🌙

## Install

```
npm install dark-mode-toggle-animation
```

## Example Usage

<img src="https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jupu9tle0bcf2fx93xeq.gif" width="300px" height="300px">

```
import DarkModeToggle from "dark-mode-toggle-animation";
import { useState } from "react";

const YourComponent = () => {

  const [darkMode, setDarkMode] = useState(true);

  const onClick = () => setDarkMode((prev) => !prev);

  return (
    <div
      style={{
        backgroundColor: `${darkMode ? "#282c34" : "#f0f0f0"}`,
        transition: "background-color 1s ease",
      }}
    >
      <DarkModeToggle
        mode={darkMode ? "sun" : "moon"}
        onClick={onClick}
        width="100px"
        moonColor="#000000"
        sunColor="#ffffff"
        animationDuration={1}
      />
    </>
  );
};
```

## Props

| Props             | Description                 | Required                    |
| ----------------- | --------------------------- | --------------------------- |
| mode              | "sun" or "moon" (string)    | Required                    |
| onClick           | toggle function (function)  | Required                    |
| width             | css width property (string) | Optional (default 100px)    |
| moonColor         | css color (string)          | Optional (default black)    |
| sunColor          | css color (string)          | Optional (default white)    |
| animationDuration | animation length (integer)  | Optional (default 1 second) |

---
_Source: https://npm.io/package/dark-mode-toggle-animation · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
