# donavon/use-dark-mode

A custom React Hook to help you implement a "dark mode" component.

Repository: https://github.com/donavon/use-dark-mode
Canonical: https://ross.abutalabs.com/products/use-dark-mode
Language: JavaScript
License: MIT
License Family: permissive
Topics: react, hooks, dark-theme, dark-mode
Last push: 2023-01-03T15:59:16+00:00

## Health v2 (maintenance only)
Score: 32/100 (v2, computed 2026-09-02T17:46:02.011165+00:00)
- activity 0, release rhythm 35, longevity 100
- inputs: {"age_days": 2788, "days_push": 1338, "days_rel": null, "gap_med": null, "n_releases_24m": 0}
- flags: no_releases
- formula: round(0.45*activity + 0.35*rhythm + 0.20*longevity); archived -> min(score, 10)

## Adoption (not part of the score)
Stars 1282, forks 95 (observed 2026-08-28T04:04:13.957128+00:00)

## What it is
A custom React Hook that implements dark mode toggling for React applications. It persists the user's preference to localStorage, syncs state across tabs, respects the system's prefers-color-scheme setting, and supports SSR.

## Use cases
- add a dark mode toggle to a react app
- persist user theme preference in localstorage
- sync dark mode state across browser tabs
- follow system dark mode preference with prefers-color-scheme
- toggle a css class on body for theming
- implement dark mode in a server-side rendered react app

## When to choose
- you use React 16.8+ and want a small, focused hook for dark mode
- you want persistence, cross-tab sync, and system preference detection out of the box
- you need SSR support for theme switching

## When to avoid
- you don't use React
- you need full theming/design-token management rather than a simple light/dark toggle
- you need a framework-agnostic or vanilla JS solution

## Facets
- artifact type: library
- maturity: maintenance
- function: state-management, ui-components, theme
- domain: frontend, web-development
- platform: browser
- tags: react-hooks, dark-mode, dark-theme, localstorage, prefers-color-scheme, ssr, nodejs

## Member repositories
- donavon/use-dark-mode (main) score 32

## Provenance
- Observed fields: from GitHub, fetched 2026-08-28T04:04:13.957128+00:00.
- Health v2: computed from the inputs above; adoption is never an input.
- Inferred fields (summary, facets, guidance): AI-extracted, prompt v1, taxonomy v1, on 2026-08-30T04:57:41.977159+00:00, confidence not recorded.
  - readme: https://github.com/donavon/use-dark-mode (fetched 2026-08-28T04:04:13.957128+00:00, sha 89033164fdba)
  - registry_npm: https://registry.npmjs.org/use-dark-mode (fetched 2026-08-29T12:12:56.344704+00:00, sha 7fa72980749d)
- Data as of 2026-08-30T08:39:29.467469+00:00.
