Prerequisites
Before installing themes, ensure you have shadcn/ui set up in your Remix project. If you haven’t already:Installation
Install the theme system
Install the complete theme system with all 40+ themes:This installs:
lib/themes-config.ts- Theme configuration and metadatalib/sessions.server.ts- Server-side session managementcomponents/mode-toggle.tsx- Theme toggle componentapp/routes/action.set-theme.ts- Theme action routestyles/themes/*.css- All 40+ theme CSS filesremix-themesdependency for SSR theme support
Configure theme session in root loader
Update your
app/root.tsx to add the theme session resolver:app/root.tsx
Add the ModeToggle to your UI
Import and use the ModeToggle component anywhere in your app:
app/components/Header.tsx
How it works
The Remix adapter uses remix-themes for server-side rendering with cookie-based session storage:Session configuration
Session configuration
Located at Themes are stored in HTTP-only cookies, making them available on the server for SSR.
lib/sessions.server.ts:Theme action route
Theme action route
Located at This route handles theme changes from the client. The
app/routes/action.set-theme.ts:remix-themes package automatically creates the action handler.ModeToggle component
ModeToggle component
Located at
components/mode-toggle.tsx:Preventing flash of wrong theme
Preventing flash of wrong theme
The This component injects an inline script that runs immediately, setting the theme before any content renders.
PreventFlashOnWrongTheme component prevents FOUC by applying the theme before React hydrates:Adding individual themes
To install specific themes instead of all 40+:app/styles/themes/index.css
Customizing themes
All theme CSS files are inapp/styles/themes/. Each theme defines CSS variables:
app/styles/themes/github.css
TypeScript usage
Use theuseTheme hook from remix-themes:
Server-side theme access
Access the current theme in loaders and actions:Production deployment
Before deploying to production:Next steps
Browse Themes
Explore all 40+ available themes
Theme Picker
Preview themes in real-time
Next.js Setup
Install themes in Next.js
Astro Setup
Install themes in Astro