darkmode-react-component
v0.1.10
Published
**Effortlessly toggle between light and dark modes in your React projects!** A simple yet powerful component for bringing dark mode to your users. Give your application the look it deserves, day or night! ππ
Downloads
14
Readme
π DarkMode-React
Effortlessly toggle between light and dark modes in your React projects! A simple yet powerful component for bringing dark mode to your users. Give your application the look it deserves, day or night! ππ
π π Live Preview
π Table of Contents
- βοΈ Installation Guide
- π‘ Basic Usage
- βοΈ Props & Customization
- π¨ Style Customization
- π Component Details
- β Show Some Love!
- π Join the Dark Side... Or Not!
βοΈ Installation Guide
Get started in seconds with npm! π―
npm install --save darkmode-react-component
π‘ Basic Usage
Add DarkModeReact to your project with just a few lines:
import DarkModeReact from 'darkmode-react-component';
<DarkModeReact />
And thatβs it! Your users can now switch between themes seamlessly! β‘
βοΈ Props & Customization
Fine-tune the behavior of your dark mode switch with these props:
π hiddenLabel
Hide the default label for a cleaner look:
<DarkModeReact hiddenLabel />
ποΈ hiddenIcon
Prefer no icons? This oneβs for you:
<DarkModeReact hiddenIcon />
π labelDark
& π labelLight
Customize the labels for a personal touch:
<DarkModeReact labelDark="Tema escuro" labelLight="Tema claro" />
π¨ Style Customization
Match the theme switch to your brandβs identity! Hereβs how you can modify the colors:
body {
--dm-color-primary: #41b883; /* Primary color */
--dm-color-secondary: #34495e; /* Secondary color */
--dm-color-text: #222; /* Text color in light mode */
--dm-color-background: #fff; /* Background color in light mode */
}
body.darkmode {
--dm-color-text: #fff; /* Text color in dark mode */
--dm-color-background: #222; /* Background color in dark mode */
}
π‘ Pro Tip: Use custom CSS variables to ensure consistency across your app, and let the .darkmode
class do the magic! β¨
π Component Details
When you use DarkModeReact, the following happens:
- β
The
body
tag gets a.darkmode
class based on the current theme. - πΎ A
LocalStorage
key saves the user's theme preference, so their choice sticks even when they refresh the page! - π¨ Style your app's components by targeting
.darkmode
in your stylesheets.
Why choose DarkModeReact?
- β‘ Quick to implement: Integrate in just a few lines.
- π¨ Highly customizable: Tweak styles to match your brand.
- π Universal appeal: Users love dark mode, and itβs better for their eyes!
- πͺ Optimized for performance: Fast, efficient, and user-friendly.
β Show Some Love!
Found this component useful? Star β the repository, share it with fellow developers, and contribute your ideas! Let's build a stylish and accessible web, together! π
Got any suggestions or issues? Head over to the Issues section or open a Pull Request. Contributions are always welcome! π
π Join the Dark Side... Or Not!
DarkMode-React makes it easy to let users decide their preferred experience. With smooth transitions, customizable styles, and a straightforward setup, itβs the perfect addition to any modern React app.