Toggle between Light and Dark Mode using Tailwind CSS & Vanilla JS

  Рет қаралды 11,251

Thirus

Thirus

Күн бұрын

Пікірлер: 72
@danielrodas7692
@danielrodas7692 3 жыл бұрын
My go-to person for all Tailwind CSS related. Thank you! 🙏🏽
@Thirus
@Thirus 3 жыл бұрын
Aww! Thanks ☺️
@Vladimir-yh2dl
@Vladimir-yh2dl Жыл бұрын
Great video tutorial on how to implement toggle between Light and Dark mode using Tailwind CSS & Vanilla JS! Thanks for sharing such a useful and informative tutorial. I found it very easy to follow along and was able to successfully implement the toggle functionality on my website. Your step-by-step instructions and clear explanations really helped me understand the process. Thank you again for creating this helpful resource!
@Thirus
@Thirus Жыл бұрын
Thank you Vladimir :) So happy to know this!
@austineukpo5153
@austineukpo5153 11 күн бұрын
thank you, that was indeed a very helpful tip 🙏
@Thirus
@Thirus 11 күн бұрын
You’re welcome!
@Nand00Coelho
@Nand00Coelho 4 жыл бұрын
Your video really helped me on the company's project. Thank you!
@Thirus
@Thirus 4 жыл бұрын
So glad! You’re welcome 😊
@thisisthelogic
@thisisthelogic 3 жыл бұрын
Wonderful, thank you!
@Thirus
@Thirus 3 жыл бұрын
You’re welcome!
@samuelnmeje
@samuelnmeje 4 жыл бұрын
Thank you so much. I am happy and feel at home that you use tailwind. I have so much to learn
@Thirus
@Thirus 4 жыл бұрын
You’re welcome! Many more Tailwind videos coming up. Let me know if you have and particular topics you’d want to see
@samuelnmeje
@samuelnmeje 4 жыл бұрын
@@Thirus hahahah a list of things i don't understand might be a lengthy blog post. I just love your style of explaining things. and i found ur video helpful at this particular time.
@Thirus
@Thirus 4 жыл бұрын
Very happy to know. Stay tuned!
@MarkMutai
@MarkMutai 3 жыл бұрын
really awesome and straightforward. Thank you!
@Thirus
@Thirus 3 жыл бұрын
You’re welcome 😊
@dev_jeongdaeri
@dev_jeongdaeri 3 жыл бұрын
you deserve more subs!!!!!! super amazing tutorials!!
@Thirus
@Thirus 3 жыл бұрын
Thanks a lot 😊
@aj4819
@aj4819 3 жыл бұрын
Thank you! This helped me a lot and thanks to you it was very easy to follow.
@Thirus
@Thirus 3 жыл бұрын
Glad to hear that 😊
@AimerYui
@AimerYui 4 жыл бұрын
another useful video, thanks 😁
@Thirus
@Thirus 4 жыл бұрын
You’re welcome 😊 Stay tuned for more
@adepurnama1642
@adepurnama1642 3 жыл бұрын
This channel is so underrated, simply amazing content, thank you!
@Thirus
@Thirus 3 жыл бұрын
Thank you so much 😊
@emmanuellemikan696
@emmanuellemikan696 2 жыл бұрын
Thank you very much for this
@Thirus
@Thirus 2 жыл бұрын
You’re welcome :)
@supriyosarkar1806
@supriyosarkar1806 4 жыл бұрын
I just started learning and using tailwind css in my projects yesterday and uploaded this video at the right time . Thank you ma'am . Happy New year ma'am.
@Thirus
@Thirus 4 жыл бұрын
That’s amazing to know! You’re welcome 😊 And wish you too a very happy new year 🎉
@aswin123adam
@aswin123adam 4 жыл бұрын
Great Video . Never really tried tailwindcss before but it seems pretty simple , will try to go through the docs and give it a try . Looking forward for the next videos .
@Thirus
@Thirus 4 жыл бұрын
Great! Do check out the introduction video and all other Tailwind CSS videos in the same playlist and you’ll get familiar in no time 😊
@stephenlau2845
@stephenlau2845 3 жыл бұрын
Hi, Thanks for your sharing, How can I change my logo image when I use dark mode toggled ? Thanks again...!
@Thirus
@Thirus 3 жыл бұрын
Add both images one after the other. Use the classes “block dark:hidden” on the logo image for light mode. Use “hidden dark:block” for the logo for dark mode.
@johnifemezuo2641
@johnifemezuo2641 3 жыл бұрын
thanks your video was helpful
@Thirus
@Thirus 3 жыл бұрын
You’re welcome!
@hafeezpp
@hafeezpp 3 жыл бұрын
Amazing
@Thirus
@Thirus 3 жыл бұрын
Glad you liked it!
@abhinaygunjal9374
@abhinaygunjal9374 3 жыл бұрын
Can you please make a video on how to retain the dark mode after refreshing the page? I am not able to understand the article.
@Thirus
@Thirus 3 жыл бұрын
You need to use localStorage for that. I have implemented it in this video - kzbin.info/www/bejne/hKfSiqVtmrZljtE It uses AlpineJS but the concept is same
@abhinaygunjal9374
@abhinaygunjal9374 3 жыл бұрын
@@Thirus ma'am, in the function mentioned here, I added two lines First to the true part Localstorage.add('dark') Then to the else part Localstorage.removeItem('theme') It works on the console showing dark mode is retained but on screen it switches back to light mode I even added the official tailwind code for the flickering part in the head tag as well. Please help this is for the final stages of the project.
@Thirus
@Thirus 3 жыл бұрын
Can’t understand much from this. DM on Twitter and share your code
@abhinaygunjal9374
@abhinaygunjal9374 3 жыл бұрын
@@Thirus did ma'am. I have shared the snippet on twitter
@belkocik
@belkocik 3 жыл бұрын
What if there is no tag in next.js project? :D Just apply to pages/index.js tag?
@Thirus
@Thirus 3 жыл бұрын
Yes, you could do that too
@garbjorn1757
@garbjorn1757 3 жыл бұрын
_app.js add className="dark"
@puneetsingh9678
@puneetsingh9678 3 жыл бұрын
If I set darkMode: "class" then would that recognise if the os is set to dark and automatically switch as well?. If not then, if I have to use functionality of both "class" and "media", what are my options?
@Thirus
@Thirus 3 жыл бұрын
That's a really good question. So, I found out that using the `prefers-color-scheme` media feature, you can detect if the user has the dark mode turned on. (That's what Tailwind also uses under the hood). So, keeping everything as it is, in Javascript, use this line to detect if user has turned on dark mode: if(window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) { } Within the block, add the ‘dark’ class to body. Hope this helps :)
@puneetsingh9678
@puneetsingh9678 3 жыл бұрын
@@Thirus Thanks 👍
@syahidann7675
@syahidann7675 3 жыл бұрын
thank you!! you help me a lot❤️
@Thirus
@Thirus 3 жыл бұрын
You’re welcome 😊
@kieran2347
@kieran2347 4 жыл бұрын
Yet another amazing video, Shruti. I see why you love TailwindCSS lol. It takes time to know and remember the class names but its worth the time and practice. Wishing you happy and a prosperous new year in advance. 💗
@Thirus
@Thirus 4 жыл бұрын
You’re right, it’s totally worth. And you actually don’t have to remember. Intuitively you can type and the intellisense plugin shows suggestions. Wishing you a very happy new year too!
@ashutoshbw
@ashutoshbw 3 жыл бұрын
Thank you very much ma'am. It was very helpful :)
@Thirus
@Thirus 3 жыл бұрын
You’re welcome 😊
@rakaa31
@rakaa31 3 жыл бұрын
but whenever i click to another page it becomes light
@Thirus
@Thirus 3 жыл бұрын
Yes, you can use localStorage to save the users choice and switch to that on page load.
@PauloGuerraF
@PauloGuerraF 4 жыл бұрын
Hi, awesome video! Thank you very much for the detailed explanation. I have a question, is there any chance to animate the transition between light and dark mode? Would like to add some easing and timing when switching modes.
@Thirus
@Thirus 4 жыл бұрын
I’m not sure if there’s a straight forward way to do that
@PauloGuerraF
@PauloGuerraF 4 жыл бұрын
Thank you@@Thirus ! I found github.com/jjranalli/nightwind very helpful to implement timed transitions between dark and light mode
@Anthony-ec8mz
@Anthony-ec8mz 3 жыл бұрын
thank you :)
@Thirus
@Thirus 3 жыл бұрын
You’re welcome
@somerandomchannel382
@somerandomchannel382 3 жыл бұрын
I love the idea but dark mode part could be a single video maybe 2min long? maybe included source code on github?
@kingofrock37
@kingofrock37 3 жыл бұрын
thank you
@Thirus
@Thirus 3 жыл бұрын
You’re welcome 😊
@miformadepensar
@miformadepensar 3 жыл бұрын
How do a lot lines in js vue or reactive: Component javascript methods:{ darkmode: function(){ document.querySelector('html').classList.toggle('dark') } } only javascrip mode. document.getElementById('darkmode').addEventListener('click', function(){ document.querySelector('html').classList.toggle('dark') }) thanks for you workshop is very cool.!
@abhipshasahu2868
@abhipshasahu2868 3 жыл бұрын
Awesome! Thank you so much! Could you attach the source code for this in the description?
@kieran5746
@kieran5746 3 жыл бұрын
This is another great tutorial, thank you. Unfortunately, there is an issue with JavaScript and the point of having a dark mode toggle. The JavaScript should account for saving the preference and automatically checking the box when a visitor switches between pages or refreshes. As it stands the state is forgotten and requires a user to toggle the dark mode again for each page load. Would it be possible for you to reply and let me know what that JavaScript would look like? Thanks again.
@Thirus
@Thirus 3 жыл бұрын
Yes, this tutorial is very basic. It's a starting point for dark mode implementation. You can check this blog post for that functionality - blog.prototypr.io/create-your-own-dark-mode-using-js-css-variables-and-localstorage-8b461864644b
@catmonster7671
@catmonster7671 3 жыл бұрын
I do as the video tutorial, but the switcher did not move when I click it. I don't know how to solve the problem.LOL
@Thirus
@Thirus 3 жыл бұрын
Oh! DM me on Twitter if you need help - twitter.com/shrutibalasa
@shreyaagarwal9498
@shreyaagarwal9498 4 жыл бұрын
Please provide source code. :)
@Thirus
@Thirus 4 жыл бұрын
Will upload on GitHub and provide the link. Kindly check back tomorrow 😊
@mushypeeze3545
@mushypeeze3545 3 жыл бұрын
Try slowing down, and providing the whole code, some of these parts were very difficult to keep up with you as you went far too fast and skipped over important parts.
Recreate Bootstrap Grid System in Tailwind CSS
24:55
Thirus
Рет қаралды 6 М.
The Best Way to Handle Dark Mode with TailwindCSS
3:49
Tom Is Loading
Рет қаралды 38 М.
Their Boat Engine Fell Off
0:13
Newsflare
Рет қаралды 15 МЛН
GIANT Gummy Worm #shorts
0:42
Mr DegrEE
Рет қаралды 152 МЛН
Every team from the Bracket Buster! Who ya got? 😏
0:53
FailArmy Shorts
Рет қаралды 13 МЛН
Light & Dark Mode toggle using Tailwind CSS & Alpine JS
19:30
Easily Set Up Tailwind CSS with Vanilla JavaScript in 10 Minutes
11:16
8 DARK MODE Websites to Copy NOW
15:10
Payton Clark Smith
Рет қаралды 24 М.
Dark mode with TailwindCSS in under 7 minutes
6:58
Built With Code
Рет қаралды 46 М.
Tailwind CSS | Dark & Light Theme Switcher
8:54
John Komarnicki
Рет қаралды 69 М.
Style your email views with Tailwind CSS using Maizzle
15:57
Subgrid in Tailwind CSS - You didn’t know you needed this
14:12
Their Boat Engine Fell Off
0:13
Newsflare
Рет қаралды 15 МЛН