https://github.com/livresaber/darkmode-react
Componente DarkMode com React
https://github.com/livresaber/darkmode-react
darkmode hacktoberfest javascript lightmode react
Last synced: 4 months ago
JSON representation
Componente DarkMode com React
- Host: GitHub
- URL: https://github.com/livresaber/darkmode-react
- Owner: livresaber
- Created: 2022-10-27T01:39:22.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2025-01-29T03:19:50.000Z (over 1 year ago)
- Last Synced: 2025-04-08T12:06:09.456Z (about 1 year ago)
- Topics: darkmode, hacktoberfest, javascript, lightmode, react
- Language: TypeScript
- Homepage: https://darkmode-react.web.app
- Size: 1.45 MB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
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](https://darkmode-react.web.app)**
---
## π **Table of Contents**
- [βοΈ Installation Guide](#οΈ-installation-guide)
- [π‘ Basic Usage](#-basic-usage)
- [βοΈ Props & Customization](#-props--customization)
- [π¨ Style Customization](#-style-customization)
- [π Component Details](#-component-details)
- [β Show Some Love!](#-show-some-love)
- [π Join the Dark Side... Or Not!](#-join-the-dark-side-or-not)
---
## βοΈ **Installation Guide**
Get started in seconds with npm! π―
```bash
npm install --save darkmode-react-component
```
---
## π‘ **Basic Usage**
Add **DarkModeReact** to your project with just a few lines:
```tsx
import DarkModeReact from 'darkmode-react-component';
```
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:
```tsx
```
### ποΈ `hiddenIcon`
Prefer no icons? This oneβs for you:
```tsx
```
### π `labelDark` & π `labelLight`
Customize the labels for a personal touch:
```tsx
```
---
## π¨ **Style Customization**
Match the theme switch to your brandβs identity! Hereβs how you can modify the colors:
```css
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.