Styling and Theming
Customize the look and feel of your ShadcnKit project
ShadcnKit uses a combination of Tailwind CSS and CSS variables for styling, allowing for easy customization and theme switching. This guide will walk you through the styling setup and how to customize it.
Global CSS Setup
The global CSS file is located at styles/globals.css
. This file contains the base styles and CSS variables for theming.
Customizing CSS Variables
You can customize the theme by modifying the CSS variables. ShadcnKit uses a set of predefined variables for colors, spacing, and other design tokens.
Here’s an example of customized CSS variables:
To apply these custom styles:
- Open
styles/globals.css
- Replace the existing
:root
and.dark
sections with your custom CSS variables
Theme Provider
ShadcnKit uses Next.js’ built-in theme support through the next-themes
package. The theme provider is set up in app/theme-provider.tsx
:
This provider is then used in the root layout (app/layout.tsx
) to enable theme switching:
Customizing Themes
To create custom themes or modify existing ones:
- Use the Shadcn UI Theme Generator to generate your desired color scheme.
- Copy the generated CSS variables.
- Paste them into your
styles/globals.css
file, replacing or modifying the existing:root
and.dark
sections.
Using Themes in Components
With the theme set up, you can use the theme variables in your components:
Switching Themes
ShadcnKit provides a theme toggle component out of the box.
Best Practices
- Use Tailwind classes for most styling needs.
- Utilize the predefined CSS variables for consistent theming.
- Use the
dark:
variant in Tailwind classes for dark mode specific styles.
By following this guide, you can easily customize the look and feel of your ShadcnKit project while maintaining the benefits of Tailwind CSS and easy theme switching.