• Stars
    star
    281
  • Rank 147,023 (Top 3 %)
  • Language
    TypeScript
  • License
    MIT License
  • Created almost 4 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

🌓 A React Hook for adding a dark / night mode to your site.

English | 简体中文

react-darkreader

React Darkreader

🌓 A React Hook for adding a dark / night mode to your site inspired by darkreader

npm npm dumi license jsdelivr

Live Demo https://react-darkreader.vercel.app

Getting Started

Install with yarn

yarn add react-darkreader

Or you can

npm install react-darkreader

Or inject the script at your page by jsdelivr CDN

<script src="https://cdn.jsdelivr.net/npm/react-darkreader@latest/dist/index.min.js"></script>

🚀 Usage

You can import the darkmode as a react component.

import React from 'react';
import Darkreader from 'react-darkreader';

export default () => <Darkreader />;

You can also create darkmode by the react hook useDarkreader

import React from 'react';
import { Switch, useDarkreader } from 'react-darkreader';

export default () => {
  const [isDark, { toggle }] = useDarkreader(false);

  return <Switch checked={isDark} onChange={toggle} />;
};

📔 API

Component

<Darkreader
  defaultDarken
  theme={/** Theme options **/}
  fixes={/** Contains fixes for the generated theme **/}
  onChange={isDark => {
    /** Callback for change **/
  }}
/>

Hook

const [isDark, { toggle, collectCSS }] = useDarkreader(defaultDarken, theme?, fixes?)

with a toggle button as ui.

<Switch checked={isDark} onChange={toggle} />

Result

Params Description Type
isDark The status of current darkmode, support true, false boolean
toggle The function for toggling the darkmode. () => void
collectCSS The async function for collecting the css of darkmode. async () => Promise<string>

Params

Params Description Type Default
defaultDarken The default status of the darkreader boolean false
theme The options of darkreader Theme refered to index.d.ts → Partial<Theme> -
fixes Contains fixes for the generated theme refered to index.d.ts → DynamicThemeFix -

🔢 Coming Soon

  • add the material design styling in switch
  • followSystemColorScheme
  • localstorge
  • playground for editing the config online

🔨 Contribute

Install dependencies,

$ npm i

Start the dev server,

$ npm start

Build documentation,

$ npm run docs:build

Build library via father-build,

$ npm run build

🥇 Who is using

Ant Design Pro Components Light Ant Design Pro Components Dark
Procomponents Light Procomponents Dark

More here → Welcome to submit.

❤️ Contributors

Thanks goes to these people:

Contributors

Please Feel free to enjoy and participate in open source!

Stargazers

Thanks for your star!

Stargazers repo roster for @Turkyden/react-darkreader

Follow Me

这是作者的微信「视频号」,每天分享一些有趣的 SaaS 软件产品,欢迎关注 ~

License

MIT

More Repositories

1

lizhi

🎸 李志 (B 仔) 音乐作品跨平台播放器,支持 Web / Mac / Windows / Linux
TypeScript
868
star
2

vue-typical

🐡 Vue Animated typing in ~400 bytes of JavaScript
TypeScript
175
star
3

watermark-pro

💦 保护你的敏感信息,一款所见即所得的证件加水印工具
TypeScript
147
star
4

image-hover

💄 No Javascript, image hover effects you've always wanted
Vue
50
star
5

geek-resume

💼 纯 Markdown,一套专为开发者量身定制的优雅简历模板
TypeScript
29
star
6

wechat-link

🥕 微信公众号无法外链怎么办?一行代码搞定长按识别二维码。
TypeScript
20
star
7

dengju-gpt

A ChatGPT APP < 100 lines of code
HTML
9
star
8

awesome-fe-teams

☎️ 中国前端梦之队,厂牌黄页龙虎榜
TypeScript
8
star
9

guitarhub

Programmer's favorite Chinese music score resource sharing platform.
HTML
6
star
10

strapi-provider-upload-tencent

Tencent Cloud COS provider for strapi upload
JavaScript
5
star
11

lowcode-weekly

低代码周刊,分享国内外低代码(LCAP)领域的一些见闻,技术难点,行业研究报告。
4
star
12

handsome-elements

💠 A portal elements for application dashboad. 企业级中后台物料库
TypeScript
3
star
13

wx-xxw

我的第一个微信全栈小程序,Egg.js+RestfulApi+WX+Mysql
JavaScript
3
star
14

electron-boilerplate

A boilerplate of fullstack electron application width Nodejs+React+ Typescript.
TypeScript
3
star
15

bit-coin

A chart of bit coin 10 years.
JavaScript
2
star
16

baby-pet

A plateform designed for the information publish about pet service.
TypeScript
2
star
17

digital-go

☄️ A WYSIWYG editor for digital big screen kanban solution.
TypeScript
2
star
18

use-vuejs

🥑 A React Hook similar to the Vuejs API.
TypeScript
1
star
19

icon-c4d

An icon with c4d style deved by react.
TypeScript
1
star
20

awesome-ot

About the operational transformation core tech.
1
star
21

tailwindcss-china

国内最活跃的,资源最丰富的 TailwindCSS 开发者社区
TypeScript
1
star
22

wudao-design

Vue
1
star
23

xrstudio

No Code, WYSIWYG, Web AR, Create your own augmented reality content without code.
TypeScript
1
star
24

awesome-xr

😎 国内元宇宙 AR/VR 开发者黄页
1
star
25

koutu

Remove Background WebGPU. In-browser background removal, powered by 🤗 Transformers.js
JavaScript
1
star
26

ComfyUI-China

a china park for comfyui
HTML
1
star
27

react-typing-hook

Animated typing in ~400 bytes 🐡 of React Hook.
TypeScript
1
star
28

react-icon-dance

A icon dance style cpmponent deved with react.
TypeScript
1
star
29

ComfyUI-Comic

a comfyui plugin for image to comic
Python
1
star
30

use-typical

Animated typing in ~2.6 kb 🐡 with React Hook.
TypeScript
1
star
31

react-slide-pane

Slide-Pane React component, can be splited vertically or horizontally to the difference between two images!
TypeScript
1
star
32

buddha-gpt

TypeScript
1
star