Skip to content
/ react-darkreader Public template
forked from turkyden/react-darkreader

πŸŒ“ A React Hook for adding a dark / night mode to your site inspired by darkreader.

License

Notifications You must be signed in to change notification settings

Korhm/react-darkreader

Β 
Β 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

35 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Getting Started

πŸŒ“ 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

darkreader

πŸ“¦ Install

yarn add react-darkreader

Or you can:

npm install react-darkreader

πŸš€ 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 isDark={isDark} onToggle={toggle} />;
};

πŸ“” API

Component

<Darkreader
  defaultDarken
  options={
    brightness: 100,
    contrast: 90,
    sepia: 10
  }
/>

Hook

const [isDark, toggle, collectCSS] = useDarkreader(defaultDarken: boolean, options?: Options);

with a toggle button as ui.

<Switch isDark={isDark} onToggle={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

Options

Params Description Type Default
brightness The brightness properties of darkmode number 100
contrast The contrast properties of darkmode number 90
sepia The sepia properties of darkmode number 10

πŸ”’ Coming Soon

  • 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

License

MIT

About

πŸŒ“ A React Hook for adding a dark / night mode to your site inspired by darkreader.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 62.1%
  • CSS 37.9%