# dark-mode-react

> React 'dark mode' component

Latest version **0.2.6** (published 2022-12-28) · MIT license · 0 weekly downloads

## Install

```sh
npm install dark-mode-react
pnpm add dark-mode-react
yarn add dark-mode-react
bun add dark-mode-react
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.6 |
| Published | 2022-12-28 |
| First published | 2022-10-09 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 10.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 5 |
| Author | Artsiom Pchaliankou |
| Maintainers | craziestbee |
| Keywords | react, theme, dark, component, react-component, dark-mode, dark-light, dark-light-mode, swith, theme-swither, toggle, theme-toggle, react-theme-toggle |

## Links

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

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 0.2.6 (latest) — 2022-12-28
- 0.2.5 — 2022-12-28
- 0.2.4 — 2022-12-28
- 0.2.3 — 2022-12-28
- 0.2.2 — 2022-12-22
- 0.2.1 — 2022-10-18
- 0.2.0 — 2022-10-10
- 0.1.9 — 2022-10-10
- 0.1.8 — 2022-10-10
- 0.1.7 — 2022-10-09
- 0.1.6 — 2022-10-09
- 0.1.5 — 2022-10-09
- 0.1.4 — 2022-10-09
- 0.1.2 — 2022-10-09

## README

# dark-mode-react

[![Npm package version](https://badgen.net/npm/v/dark-mode-react)](https://npmjs.com/package/dark-mode-react)
[![Npm package total downloads](https://badgen.net/npm/dt/dark-mode-react)](https://npmjs.com/package/dark-mode-react)
[![Npm package daily downloads](https://badgen.net/npm/dw/dark-mode-react)](https://npmjs.com/package/dark-mode-react)
[![Npm package daily downloads](https://badgen.net/npm/dd/dark-mode-react)](https://npmjs.com/package/dark-mode-react)
[![Npm package license](https://badgen.net/npm/license/lodash)](https://npmjs.com/package/dark-mode-react)

> NOTE: react dark mode based on "react": "^18.2.0" and "react-dom": "^18.2.0".
> The user setting persists to `localStorage`.

### dark-mode-react:

<ul>
    <li>a minimal lightweight component for your React projects.</li>
    <li>quickly setup</li>
    <li>has a small bundle size and zero dependencies</li>
    <li>you have total control with styles - css, scss, sass, tailwind ui.</li>
    <li style="color: red"><b>Doesn't support Vite and TS</b></li>
</ul>

### If you would like to switch your React app on [Vite](https://vitejs.dev/) or [TypeScript](https://www.typescriptlang.org/docs/handbook/react.html) or both of them. Install [dark-mode-ts](https://www.npmjs.com/package/dark-mode-ts) version. 

Don't forget about ⭐ [GitHub](https://github.com/ArtemPchela/dark-mode-react)

```jsx
import React from 'react';
import {Theme} from "dark-mode-react";
import yourDarkImage from './path/to/your/DarkImage.png'
import yourLightImage from './path/to/your/LightImage.png'

const NameYourComponent = () => {
  return (
    <div>
      <Theme
        darkIcon={yourDarkImage}
        lightIcon={yourLightImage}
        altDark='dark icon'
        altLight="light icon"
        imgWidth='50'
        imgHeight='50'
        myClass="your-class_name"
      />
    </div>
  )
};
```

A React theme component accepts the following props:

| Key         | Type   | Description                                                          |
|:------------|:-------|:---------------------------------------------------------------------|
| `darkIcon`  | -      | Work with .png, .jpg, .svg<sup>*</sup> extensions.                   |
| `lightIcon` | -      | Work with .png, .jpg, .svg<sup>*</sup> extensions.                   |
| `altDark`   | string | For better accessibility.                                            |
| `altLight`  | string | For better accessibility.                                            |
| `imgWidth`    | string | Width for your icon.                                                 |
| `imgHeight`   | string | Height for your icon.                                                |
| `myClass`   | string | If you want to have background or add hover effect for icon wrapper. |

<sup>*</sup> - Don't **forget**, **svg** has width and height by **default**.

## Add your global styles. Example:

```css
:root {
  --background-color: #007aff;
  --color-text: white;
}

[data-theme='light'] {
  --background-color: #227d2c;
  --color-text: black
}

body {
  background: var(--background-color);
  color: var(--color-text);
}
```

## Installation

```sh
$ npm i dark-mode-react
```

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