Getting Started
Requirements
Installation
npm install react-color-mode
# OR
yarn add react-color-modeUsage
Setup your styles
/* Set default light mode colors on <html> */
:root {
background-color: white;
color: black;
}
/* User is in light mode, but has selected dark mode */
:root[react-color-mode="dark"] {
background-color: black;
color: white;
}
/* User is in dark mode and HAS NOT has selected light mode */
@media (prefers-color-scheme: dark) {
:root:not([react-color-mode="light"]) {
background-color: black;
color: white;
}
}Install the script
Install the Context Provider
Last updated