Skip to main content

Prerequisites

Before installing themes, ensure you have shadcn/ui set up in your Vite React project. If you haven’t already:
1

Initialize shadcn/ui

2

Install required components

The theme system requires these shadcn/ui components:

Installation

1

Install the theme system

Install the complete theme system with all 40+ themes:
This installs:
  • lib/themes-config.ts - Theme configuration and metadata
  • components/theme-provider.tsx - Custom React theme provider
  • components/theme-switcher.tsx - Interactive theme switcher UI
  • styles/themes/*.css - All 40+ theme CSS files
2

Add ThemeProvider to your app root

Wrap your application with the ThemeProvider in src/App.tsx:
src/App.tsx
3

Add the ThemeSwitcher to your UI

Import and use the ThemeSwitcher component anywhere in your app:
src/components/Header.tsx

How it works

The Vite adapter uses a custom theme provider with localStorage persistence:
Located at components/theme-provider.tsx:
The provider manages theme state and automatically updates the data-theme attribute on the document root.
All theme metadata is in lib/themes-config.ts:
Themes are automatically saved to localStorage with the key tweakcn-theme:
On page load, the theme is restored from localStorage:

Adding individual themes

To install specific themes instead of all 40+:
Then import only the themes you need:
src/styles/themes/index.css

Customizing themes

All theme CSS files are in src/styles/themes/. Each theme defines CSS variables:
src/styles/themes/vercel.css
Edit these files to customize colors, borders, shadows, and more.

TypeScript usage

Use the useTheme hook from the theme provider:

Vite configuration

Ensure your vite.config.ts has path aliases configured:
vite.config.ts

Next steps

Browse Themes

Explore all 40+ available themes

Theme Picker

Preview themes in real-time

Next.js Setup

Install themes in Next.js

Remix Setup

Install themes in Remix