Dark Mode
Last updated
Last updated
Dark mode works out of the box in this starter kit. The default theme is system. It's based on and .
The styling is in the src/app/globals.css
file. All the light mode styling is directly specified :root
selector while the styles of dark mode are under .dark
class.
The default style is system preference right now. It can be changed very easily by changing the value of defaultTheme
prop in <ThemeProvider>
tag in src/app/layout.tsx
file.
The starter kit comes with a toggle button as well. It's src/components/ModeToggle.tsx
file.
To use it, simple import in whatever file you want to show it and use it as a regular component.
If you want to use styles in your components that are not specified in globals.css
, you can do that using the dark:
variant of TailwindCSS.
Custom styles: Custom styles
I have used it myself in the kit home page, check out for reference:
Next Themes:
Shadcn/UI's dark mode docs:
TailwindCSS' dark mode docs: