# @bianic-ui/color-mode

> React component and hooks for handling light and dark mode.

Latest version **0.1.0-alpha.2** (published 2020-09-03) · MIT license · 0 weekly downloads

## Install

```sh
npm install @bianic-ui/color-mode
pnpm add @bianic-ui/color-mode
yarn add @bianic-ui/color-mode
bun add @bianic-ui/color-mode
```

## Health

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

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.0-alpha.2 |
| Published | 2020-09-03 |
| First published | 2020-09-03 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 2 |
| Unpacked size | 48 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Muhammad Rafiul Ilmi Syarifudin |
| Maintainers | ilmimris |
| Keywords | react, theming, ui, light mode, use dark mode, dark mode, color mode, hook, color scheme, media query, bianic ui |

## Links

- npm: https://www.npmjs.com/package/@bianic-ui/color-mode
- Repository: https://gitlab.com/bia-design/bianic-ui
- Homepage: https://gitlab.com/bia-design/bianic-ui#readme
- Issues: https://gitlab.com/bia-design/bianic-ui/issues
- npm.io page: https://npm.io/package/@bianic-ui/color-mode

## Dependencies (2)

- [@bianic-ui/hooks](https://npm.io/package/@bianic-ui/hooks.md) ^0.1.0-alpha.2
- [@bianic-ui/utils](https://npm.io/package/@bianic-ui/utils.md) ^0.1.0-alpha.2

## 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.1.0-alpha.2 (latest) — 2020-09-03
- 0.1.0-alpha.1 — 2020-09-03

## README

# Color Mode

React component that adds support for light mode and dark mode using
`localStorage` and `matchMedia`.

## Installation

```sh
yarn add @bianic-ui/color-mode

# or

npm i @bianic-ui/color-mode
```

## Import component

To enable this behavior within your apps, wrap your application in a
`ColorModeProvider` below the `ThemeProvider`

```jsx live=false
import * as React from "react"
import { ColorModeProvider } from "@bianic-ui/color-mode"
import theme from "./theme"

function App({ children }) {
  return (
    <ThemeProvider theme={theme}>
      <ColorModeProvider>{children}</ColorModeProvider>
    </ThemeProvider>
  )
}
```

Then you can use the hook `useColorMode` within your application.

```jsx
function Example() {
  const { colorMode, toggleColorMode } = useColorMode()
  return (
    <header>
      <Button onClick={toggleColorMode}>
        Toggle {colorMode === "light" ? "Dark" : "Light"}
      </Button>
    </header>
  )
}
```

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