Getting Started
Requirements
npm or Yarn
Node.js
React 16.8+
Installation
Usage
Setup your styles
react-color-mode
will set a special attribute on your <html>
tag, allowing you to style your site based on it.
Install the script
react-color-mode
exports a <script>
tag to be injected into your <head>
. This script allows react-color-mode
to setup the color mode before the rest of the page is loaded, preventing the page from flickering on page load. This component should be rendered as early as possible. See our recipes section for the best way to accomplish this in your app.
Install the Context Provider
The easiest way to use and update the color mode is via the Context API. This can be done with <ColorModeContextProvider>
and the useColorMode
hook.
Last updated