Тёмный
No video :(

How to Create a Dark Mode Component in React 

Alex Eagleson
Подписаться 6 тыс.
Просмотров 4,2 тыс.
50% 1

This tutorial will teach you how add a dark mode to your web page or application using a custom React component.
This video is based on my blog post, which includes a section on how to add tests to the component described in this video:
dev.to/alexeag...
To clone your own copy of this example, the code is available at this repository:
github.com/ale...

Опубликовано:

 

5 сен 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 18   
@coeurdechene314
@coeurdechene314 2 года назад
Hi! I am a beginner and I did not succeed to create a dark mode for my first app for days and days, until I found your video. How much it is reassuring and satisfying to succeed, thanks to you. Furthermore, french is my first language but I understood very well all your explanations. Everything is clear and pedagogic. Many thanks! Canadian people are definitely the best!! :D
@AlexEagleson
@AlexEagleson 2 года назад
Glad it was helpful! Best wishes from Ontario Cheers
@klutch4198
@klutch4198 2 года назад
I always like to add a simple 200ms ease transition on the toggled classes to make it smooth! Awesome video
@FunkyToe369
@FunkyToe369 2 года назад
Great little tutorial! Elegant solution and you explained each step thoroughly so if someone is unfamiliar with one or more components of how this works, they should get it after this! Well done!
@AlexEagleson
@AlexEagleson 2 года назад
High praise, thank you, it's very appreciated. Cheers.
@kishoreandra
@kishoreandra 2 года назад
great video and first video to watch of your Alex ... instant subscribe 🙌
@Alonochka1111
@Alonochka1111 Год назад
I wasted a lot of time trying to make an application with a theme change. Your video just saved me. Please keep making videos like this, share your experience with novice programmers.
@sumitdas962
@sumitdas962 2 года назад
Great content
@wayneswildworld
@wayneswildworld 2 года назад
Great video!!!
@peacecyebukayire5316
@peacecyebukayire5316 2 года назад
Keep it up Alex Amazing content
@omarsamy7209
@omarsamy7209 2 года назад
well deserved sub
@carlosarmiento
@carlosarmiento 2 года назад
Awesome!😄
@diemantrabeats7551
@diemantrabeats7551 Год назад
Great video, I had everything setup using jotai for saving the preferred theme to localStorage... this way seems a lot more convenient, I had no idea about the window.matchMedia ! That's awesome. One thing I did add with my version (where I used scss), was a mixin like... @mixin dark { html[data-theme='dark'] & { @content; } } and then I did the same for hover etc... It really helps when you run into different elements that might have colours or something so you can just say .specialButton { color: black; @include dark { color: pink; } }... Just thought I'd leave that little tip here incase any other noobs like me stumble across it and find it useful 👍🏻
@wayneswildworld
@wayneswildworld 2 года назад
I am now a sub
@davidvittal8672
@davidvittal8672 2 года назад
How much is the implementation different from NextJS? Great explanation.
@AlexEagleson
@AlexEagleson 2 года назад
Shouldn't be too different, React is mostly "along for the ride here" all the real work is done in HTML/CSS I haven't used Next.js in over a year so I can't say for sure, but it's possible you might have to put anything that references `document` or `window` (localStorage) inside whatever function Next.js uses to hold code execution until it hits the client, since those variables will not be defined in a server environment. Everything else should be the same.
@klutch4198
@klutch4198 2 года назад
@@AlexEagleson if ('window' !== undefined) {// run code here}
@klutch4198
@klutch4198 2 года назад
It's an O.G Gatsby trick I used to use when loading client side browser code from Firebase haha
Далее
How to Create and Publish a React Component Library
1:19:25
Light / Dark Mode Toggle In React Tutorial
16:02
Просмотров 98 тыс.
Moto Trial vs Moto acrobática 🏁
00:29
Просмотров 2,3 млн
НЕДОВОЛЬНА УСЛУГОЙ #shorts
00:27
Просмотров 19 тыс.
Easy Dark Mode Switch with React and localStorage
6:35
Beautiful Area Charts in React with Recharts
23:11
Просмотров 44 тыс.
Goodbye, useEffect - David Khourshid
29:59
Просмотров 499 тыс.
How to Connect a React App to a Notion Database
28:52