Skip to main content

Prerequisites

Before installing themes, ensure you have shadcn/ui set up in your Remix 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
  • lib/sessions.server.ts - Server-side session management
  • components/mode-toggle.tsx - Theme toggle component
  • app/routes/action.set-theme.ts - Theme action route
  • styles/themes/*.css - All 40+ theme CSS files
  • remix-themes dependency for SSR theme support
2

Configure theme session in root loader

Update your app/root.tsx to add the theme session resolver:
app/root.tsx
3

Add the ModeToggle to your UI

Import and use the ModeToggle component anywhere in your app:
app/components/Header.tsx
4

Update session secret (production)

Replace the default session secret in lib/sessions.server.ts before deploying to production:
lib/sessions.server.ts
Add SESSION_SECRET to your .env file:
.env

How it works

The Remix adapter uses remix-themes for server-side rendering with cookie-based session storage:
Located at lib/sessions.server.ts:
Themes are stored in HTTP-only cookies, making them available on the server for SSR.
Located at app/routes/action.set-theme.ts:
This route handles theme changes from the client. The remix-themes package automatically creates the action handler.
Located at components/mode-toggle.tsx:
The PreventFlashOnWrongTheme component prevents FOUC by applying the theme before React hydrates:
This component injects an inline script that runs immediately, setting the theme before any content renders.

Adding individual themes

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

Customizing themes

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

TypeScript usage

Use the useTheme hook from remix-themes:

Server-side theme access

Access the current theme in loaders and actions:

Production deployment

Before deploying to production:
1

Set session secret

Add a strong session secret to your environment:
2

Configure domain

Update the cookie domain in lib/sessions.server.ts:
3

Enable secure cookies

Ensure secure: true is set for production to require HTTPS.

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