Theming
NeoUI is 100% compatible with shadcn/ui themes. Use any theme from the shadcn/ui gallery, generate one with tweakcn, or write your own CSS variables.
How Theming Works
All NeoUI components use CSS custom properties (variables) for their colors, spacing, and radius. Switching a theme is as simple as swapping out those variable definitions — no recompiling, no class changes, no JavaScript framework needed.
The included theme files (_content/NeoUI.Blazor/css/themes/)
ship five base palettes and seventeen primary accent colors, giving you
85 ready-to-use combinations out of the box.
Pre-Built Theme System
Include theme CSS files in App.razor before components.css:
Base colors (5)
- zinc · slate · gray · neutral · stone
Primary accent colors (17)
- red · rose · orange · amber · yellow · lime
- green · emerald · teal · cyan · sky · blue
- indigo · violet · purple · fuchsia · pink
Production Tip
ThemeSwitcher
component to work, load all 22 theme files.
Dynamic Theme Switching
NeoUI includes a built-in theme switcher that lets users pick their preferred color combination
at runtime. Changes apply instantly without a page reload, and the selection is persisted via
localStorage.
Add the components to your layout header:
For programmatic control, inject ThemeService:
Custom CSS Theme
You can use any theme from ui.shadcn.com/themes
or tweakcn.com.
Copy the generated CSS and paste it into wwwroot/styles/theme.css:
Then reference it in App.razor before components.css:
Load Order Matters
components.css
so the CSS variables are defined when NeoUI references them.
Available CSS Variables
These are the standard shadcn/ui variables NeoUI reads. You can override any of them.
Dark Mode
Dark mode is controlled by the presence of the dark
class on the <html> element.
All NeoUI components automatically switch to dark mode colors when this class is present.
The included theme.js script initialises
the correct class on page load to prevent a flash of unstyled content.
The DarkModeToggle component handles switching:
Using Tailwind CSS Alongside NeoUI
NeoUI works out of the box without Tailwind — components.css
handles all component styling. If you want Tailwind utility classes in your own layouts and pages
(e.g. bg-primary,
text-muted-foreground,
border-border), you can
add a Tailwind v4 build pipeline to your Shared project. The key integration point is the
tailwind.config.js
— it maps all NeoUI CSS variables to named Tailwind colors, so your utility classes and
the active NeoUI theme always stay in sync automatically.
Tailwind CSS v4
tailwind.config.js-only
approach with a CSS-first configuration via
@import 'tailwindcss'.
The tailwind.config.js
is still used for content scanning and theme token extension.
1. Install Tailwind v4
Add a package.json in
your Shared project (alongside the .csproj)
and install the CLI:
Or add the packages directly to your
package.json:
2. Create the CSS input file
app-input.css is the entry
point Tailwind reads. It pulls in Tailwind v4 itself, your NeoUI CSS variable theme, and any
custom CSS you need. The compiled output is written to
app.css.
3. Configure tailwind.config.js
Place this file next to your .csproj.
The content array tells Tailwind
where to scan for class names. The theme.extend.colors
section wires every NeoUI CSS variable to a named Tailwind color — this is what makes
bg-primary or
text-muted-foreground theme-aware.
4. Integrate with the .NET build
Add MSBuild targets to your .csproj
so dotnet build automatically
runs npm install and compiles
Tailwind before the Razor project builds.
5. Reference the output CSS in App.razor
Add the generated app.css
after components.css. Use
@Assets[...] so the URL is
fingerprinted for cache invalidation. Replace YourApp.Shared
with your Shared project's assembly name.
Exclude build files from publish output
package.json,
package-lock.json, and
tailwind.config.js
to a <Content Remove="..." />
item group in your .csproj
so they are not included in the published output.