If you've created a Next.js project with shadcn/ui recently, there's a good chance dark mode is already set up.
I noticed this while looking through a fresh project. I opened app/globals.css expecting to add the theme colors, but the light and dark values were already there. Then I checked the components folder and found a theme-provider.tsx file that had already been created for me.
That raised a more useful question: if shadcn has already done most of the setup, what do you actually need to build?
In this guide, we'll look at the dark-mode setup that comes with a generated shadcn project, understand how the pieces work together, and build a theme switcher that users can control.…