Dark Mode in Next JS 13 App Directory with TailwindCSS (for beginners)

Sdílet
Vložit
  • čas přidán 26. 08. 2024

Komentáře • 103

  • @ajayrathod7438
    @ajayrathod7438 Před 7 dny

    This video was very informative. I am making my first project in next.js and i was facing issue with theme in it. with your video my all isssue are resolved. Thanks a lot!!

  • @jooncco
    @jooncco Před rokem +3

    This was the only one I found explaining within the appDir feature. Thanks a lot !!

  • @toastrecon
    @toastrecon Před rokem +19

    I could be missing something, but wouldn't this essentially make ALL of your components "client components"? I mean, you only need to wrap the components in the theme provider that you want to change when you went from light to dark mode, but that would theoretically be any and all that were visible, right?

    • @TuomoKankaanpaa
      @TuomoKankaanpaa  Před rokem +8

      Good question! As far as I understand it, by wrapping the components inside the ThemeProvider using the "providers" approach we used in this video, doesn't make the children components client components because they are passed as children for the Providers component. When we use the ThemeProvider like we did in this video, it basically wraps all components of the application inside the ThemeProvider. Hopefully this answers your question! :)

    • @matis188
      @matis188 Před rokem +5

      directly from nextjs 13 documentation:
      "use client" sits between server-only and client code. It's placed at the top of a file, above imports, to define the cut-off point where it crosses the boundary from the server-only to the client part. Once "use client" is defined in a file, all other modules imported into it, including child components, are considered part of the client bundle.

    • @sgtduckduck
      @sgtduckduck Před rokem

      @@matis188 I use this same method and I have plenty of server components inside of providers that are definitely not client components.

    • @piotrrodzen772
      @piotrrodzen772 Před 11 měsíci +1

      @@matis188 so all children will be client in the end? Would be great to have 100% clarification

    • @ap6311
      @ap6311 Před 11 měsíci +2

      @@piotrrodzen772 Yes, this tutorial doesn't follow best practices, especially with Next13

  • @over1498
    @over1498 Před rokem +1

    Returning null if !mounted is a bad workaround that will end up causing delays and long loading of certain client components. It essentially "waits" a half second or more, then your component appears. I know it's the the way Vercel says to do it, but still problematic. You can render a dummy component until it's mounted, but that's a huge duplication of effort.
    I found that Tailwind themes SOMEhow work better without any hydration error or delay. Not sure how they are getting the the theme value (probably a CSS media query in the background). But it works
    And I just typed that all out as I watched the video, not knowing you were going to get to Tailwind and explain that too!
    Good video, very helpful.

    • @TuomoKankaanpaa
      @TuomoKankaanpaa  Před rokem

      Thanks! 🙌

    • @NZTechArc
      @NZTechArc Před rokem

      considering the tailwind tutorial near the end, are you saying that this "return null" could be done better, if so how?

  • @tube-rp1nb
    @tube-rp1nb Před rokem +1

    thanks man. i have been trying for three days.this was helpfull

    • @TuomoKankaanpaa
      @TuomoKankaanpaa  Před rokem

      Great to hear that you found it helpful! Thanks for your comment :)

  • @wadethomas3736
    @wadethomas3736 Před 9 měsíci

    Thanks for this video I really appreciate it. This is the only one I found that implemented light and dark mode with the new app structure.

  • @facundoflores4763
    @facundoflores4763 Před 9 měsíci

    Thanks you saved me some time with hidratation failing.

  • @wassu8499
    @wassu8499 Před rokem

    I loved sir your best teacher teaching to everyone ❤

  • @anonymousnoob3660
    @anonymousnoob3660 Před 6 měsíci

    Thank you so Much! Saved me a ton lot of time.

  • @kacperkowalski6862
    @kacperkowalski6862 Před rokem

    My issue has been resolved by you :), nice video

  • @alexakten
    @alexakten Před 8 měsíci

    legend, solved my problem! liked and subscribed!

  • @mmd1dev
    @mmd1dev Před 11 měsíci

    Thanks for the clear and great content 💖

  • @sellimenes
    @sellimenes Před rokem +2

    There is not many videos about dark mode with App dir. Thank you for your effort and information! But, on this configuration, when a refresh the page, it blinks from light mode to dark mode. And if course, it's not a good user experience. Do you have any ideas?

    • @claudwatari
      @claudwatari Před rokem +1

      I removed the if(!mounted) return {children} and just clear the console since the "extra properties" error is development mode only. No blinking as it returns the ThemeProvider anyway even before mounting.

    • @iankco
      @iankco Před 10 měsíci

      This worked for me as well.@@claudwatari 🥳

  • @emraheskibagc3585
    @emraheskibagc3585 Před 7 měsíci

    very nice explanation, thank you

  • @frederickbruce7463
    @frederickbruce7463 Před rokem

    Great video! Thank you!

  • @nemeziz_prime
    @nemeziz_prime Před rokem +1

    Can you share info about your VS Code Themes and Extensions setup? Looks pretty cool

  • @arcsenco.3774
    @arcsenco.3774 Před rokem

    very helpful, thanks!

  • @alexisscuderi196
    @alexisscuderi196 Před 6 měsíci

    but, wrapping the entire page in a client component does not make the entire page client side? i thought once you put a parent component that is client side, all of his childrens become client side too

  • @gilbertdelaloye271
    @gilbertdelaloye271 Před rokem

    Hey man - thank you so much. I almost never comment or like videos but you helped me so so much - I just had to☺ Do you have a patreon? :)

    • @TuomoKankaanpaa
      @TuomoKankaanpaa  Před rokem

      Wow thank you very much for your comment, I'm glad to hear that the videos have been helpful!

    • @TuomoKankaanpaa
      @TuomoKankaanpaa  Před rokem

      I don't have a patreon at the moment, but if you want to support the channel by tipping you can do it here: bit.ly/3XTXNZu :)

  • @artemii8672
    @artemii8672 Před rokem

    InvalidCharacterError: Failed to execute 'add' on 'DOMTokenList': The token provided ('[object Object]') contains HTML space characters, which are not valid in tokens.

  • @kasieugwu4041
    @kasieugwu4041 Před 6 měsíci

    Thanks for the class. Next/image does not work after the page refresh in next themes

    • @kasieugwu4041
      @kasieugwu4041 Před 6 měsíci

      "What I meant is that when I do this:
      const { resolvedTheme } = useTheme();
      const arewaTheme = resolvedTheme === 'light' ? lightImage : darkImage;
      in order to choose my preferred theme, each time I refresh the page, it always defaults to 'darkImage' even though the theme is set to 'light'."

  • @midoone188
    @midoone188 Před 7 měsíci

    Thanks man , but how to use it with MUI ?

  • @MrKeliv
    @MrKeliv Před rokem

    This tutorial is very usefull. Thank you

  • @ryanhenrique9312
    @ryanhenrique9312 Před rokem

    Great video, but I have a question, the themeSwitcher works perfectly locally, but I deployed the application on vercel and my themeSwitcher is simply not rendered, what could be happening? help me plsssss

  • @claudwatari
    @claudwatari Před rokem

    Thanks for this 💻

  • @arcsenco.3774
    @arcsenco.3774 Před rokem

    Do you use tailwind for your nextjs applications or something else? I've found that material ui theme tends to work for me but always looking for new tools

  • @user-vh6jb7wc8z
    @user-vh6jb7wc8z Před rokem

    Thank you for this!!

  • @FGA-47
    @FGA-47 Před rokem

    Thanks that was so helpful❤

  • @fear0ne
    @fear0ne Před 11 měsíci

    Hi that's a great tutorial, can you tell me why when dark mode is selected and I navigate to another page it reverts to light mode and then back to dark again? Is this how this is supposed to work?

  • @guillecm_dev
    @guillecm_dev Před 10 měsíci

    Very useful!

  • @6099x
    @6099x Před rokem

    Hey thank you Tuomo 👍

  • @z1982_
    @z1982_ Před rokem +1

    Amazing, thanks a lot! At 4:52, how did you wrap automatically in vs code?

    • @TuomoKankaanpaa
      @TuomoKankaanpaa  Před rokem +2

      Thank you! That's actually not a vscode feature, it was just editing :P

    • @cwgabel
      @cwgabel Před rokem

      It is an emmet feature. Look up from the Command Palette for Emmet wrap with Abbreviation. You can also let emmet select more HTML selections with Balance Inward and Outward.

  • @amancharlamanas3812
    @amancharlamanas3812 Před rokem

    Thanks a lot brother !!

  • @aryaprima6626
    @aryaprima6626 Před rokem

    Thank you bro, its good video

  • @stpk8900
    @stpk8900 Před rokem

    Helped me a lot, thanks!🔥
    What theme of VS Code you use?

  • @JIPPOKIKKA
    @JIPPOKIKKA Před rokem

    Kokeilin tätä, niin pitääko tuo "mode" tallentaa evästeisiin koska itsellä ainakin vilkkuu sivustojen välillä eli kun vaihdan sivua niin se käy "light" teemassa ja siirtyy saman tien "dark" teemaan. Kuitenkin vilkkuu.

    • @TuomoKankaanpaa
      @TuomoKankaanpaa  Před rokem

      Aijaa 🤔 vaikea sanoa suoriltaan, se voi olla että se täytyis tallentaa johonkin. Voisko myös johtua jos ajat dev servulta sitä, eli vilkkuuko jos ajat prod buildia tai deployaat sen esim Vercel?

    • @JIPPOKIKKA
      @JIPPOKIKKA Před rokem

      @@TuomoKankaanpaa mäpä kokeilen. Ja siis selitin ehkä huonosti mut jos refreshaan sivun niin silloin eli kun useEffect ajetaan niin sen takia se vilkkuu uskoisin.

  • @ZainabSalah-xm1xy
    @ZainabSalah-xm1xy Před rokem

    this is amazing tysm

  • @piotrrodzen772
    @piotrrodzen772 Před 11 měsíci

    Thanks it was helpful t

  • @marcelee124
    @marcelee124 Před rokem

    Thank you!

  • @ajitpatil7214
    @ajitpatil7214 Před rokem

    How can we make infinite scroll in nextjs@latest 13.4 with srr .It will be very helpful if you tell me.

  • @resulabdulla3825
    @resulabdulla3825 Před 11 měsíci +1

    Bro cookie or local saved ??? 🤔🤔

  • @JIPPOKIKKA
    @JIPPOKIKKA Před rokem

    Saisko jonnekki Udemyyn suomeksi näitä. Haluisin esim yhen kurssin jossa teet ”asiakasprojekti” sivut tutoriaalina.

    • @TuomoKankaanpaa
      @TuomoKankaanpaa  Před rokem

      Kiitos palautteesta! Tällä hetkellä valitettavasti videot on vaan englanniks, mutta ehkä tulevaisuudessa voisi myös suomeks tehdä 👍

  • @user-fh7ik2jn5v
    @user-fh7ik2jn5v Před rokem

  • @wassu8499
    @wassu8499 Před rokem

    Why not upload more video ? Sir. I am wating for your video sir

    • @TuomoKankaanpaa
      @TuomoKankaanpaa  Před rokem +1

      Glad to hear you are waiting for the next videos! They are on their way and I just published a new one!

  • @shohanurshohan2300
    @shohanurshohan2300 Před 9 měsíci

    video is blurry even at 1080p

  • @tejaswavhal2626
    @tejaswavhal2626 Před rokem

    can you provide the code

    • @TuomoKankaanpaa
      @TuomoKankaanpaa  Před rokem +1

      Yes of course, sorry my bad I forgot to add them. They are now linked in the video description! :)

    • @tejaswavhal2626
      @tejaswavhal2626 Před rokem

      @@TuomoKankaanpaa Thankyou so much

  • @NZTechArc
    @NZTechArc Před rokem

    Very good content! Subscribing!
    It would be great if you did not thank those who leave a nice comment and instead answered the questions of those who need help.

    • @TuomoKankaanpaa
      @TuomoKankaanpaa  Před rokem

      Glad to hear you like the content! About answering questions, I'm trying by best sir!

  • @memduhcevik
    @memduhcevik Před 11 měsíci

    it is not suitable for SEO