In this guide, we'll learn how to set up dark mode functionality in your application using the `next-themes` library and some help from Shadcn.
Run the following command to install the required dependencies:
jrui add themeProvider
Note: This will override any custom styles you have in your globals.css file. Make sure to have those ready to paste back in after installing.
The command below is recommended for a button that toggles light and dark mode.
jrui add themeToggle
Import the `ThemeProvider` component into your layout file and wrap your {children} with it inside the body tag:
Note: You may need to restart your development server for the changes to take effect!
You now have default light and dark modes with your toggle now. If you want to try styling elements based on your modes, try using tailwind. This example shows how you can set a background color based on light and dark modes.