Install Tailwind CSS
Nexus UI components are styled with Tailwind CSS v4 and read their colours from CSS variables. If you followed the Quick Start, Tailwind is already installed; this page shows how to check, how to add it to an older project, and how the colour tokens and dark mode work.
1. Check what you already have
A project made with the command on the Quick Start (it includes --tailwind) already has Tailwind CSS v4. You can confirm it:
package.jsonliststailwindcss(version 4), together with a Tailwind plugin for your bundler:@tailwindcss/postcssor, in newer Next.js projects,@tailwindcss/turbopack.- That plugin is switched on in
postcss.config.mjs(PostCSS) or in theturbopacksection ofnext.config.ts. src/app/globals.cssstarts with@import "tailwindcss";.
If all three are true, skip to design tokens. If not, follow steps 2 and 3, which use the PostCSS setup.
2. Install Tailwind in a project that lacks it
From your project root, install Tailwind and its PostCSS plugin. Tailwind v4 needs no autoprefixer and no tailwind.config.js; configuration lives in CSS.
npm install tailwindcss @tailwindcss/postcss3. Configure PostCSS
Create postcss.config.mjs in the project root (next to package.json), or replace the one that is there:
export default {
plugins: {
"@tailwindcss/postcss": {},
},
};Then make sure src/app/globals.css begins with the import below and that src/app/layout.tsx imports the file with import "./globals.css";.
@import "tailwindcss";Design tokens and globals.css
Nexus UI components never hard-code colours. They use classes such as bg-card, text-muted-foreground and border-border, which read CSS variables defined in globals.css. Change a variable and every component follows.
If you ran npx shadcn@latest init, it has already added these variables, so do not replace your file with the block below; edit the values you want to change. If you skipped shadcn, add this block to src/app/globals.css under the import line. It uses OKLCH colours, which keep light and dark themes visually balanced, and an @theme inline block that turns each variable into a Tailwind class.
@import "tailwindcss";
/* Map CSS variables to Tailwind color/radius utilities */
@theme inline {
--color-background: var(--background);
--color-foreground: var(--foreground);
--color-card: var(--card);
--color-card-foreground: var(--card-foreground);
--color-popover: var(--popover);
--color-popover-foreground: var(--popover-foreground);
--color-primary: var(--primary);
--color-primary-foreground: var(--primary-foreground);
--color-secondary: var(--secondary);
--color-secondary-foreground: var(--secondary-foreground);
--color-muted: var(--muted);
--color-muted-foreground: var(--muted-foreground);
--color-accent: var(--accent);
--color-accent-foreground: var(--accent-foreground);
--color-destructive: var(--destructive);
--color-border: var(--border);
--color-input: var(--input);
--color-ring: var(--ring);
--radius-sm: calc(var(--radius) * 0.6);
--radius-md: calc(var(--radius) * 0.8);
--radius-lg: var(--radius);
--radius-xl: calc(var(--radius) * 1.4);
--font-sans: ui-sans-serif, system-ui, sans-serif;
--font-mono: ui-monospace, "Cascadia Code", Menlo, Monaco, Consolas, monospace;
}
/* Light mode tokens */
html {
--background: oklch(0.99 0.002 260);
--foreground: oklch(0.16 0.015 260);
--card: oklch(1 0 0);
--card-foreground: oklch(0.16 0.015 260);
--popover: oklch(1 0 0);
--popover-foreground: oklch(0.16 0.015 260);
--primary: oklch(0.28 0.02 260);
--primary-foreground: oklch(0.99 0 0);
--secondary: oklch(0.96 0.006 260);
--secondary-foreground: oklch(0.25 0.015 260);
--muted: oklch(0.96 0.006 260);
--muted-foreground: oklch(0.48 0.015 260);
--accent: oklch(0.94 0.008 260);
--accent-foreground: oklch(0.18 0.015 260);
--destructive: oklch(0.55 0.22 25);
--border: oklch(0.90 0.008 260);
--input: oklch(0.90 0.008 260);
--ring: oklch(0.38 0.02 260);
--radius: 0.625rem;
}
/* Dark mode tokens (add class="dark" to <html>) */
html.dark {
--background: oklch(0.09 0.008 260);
--foreground: oklch(0.97 0.006 260);
--card: oklch(0.13 0.006 260);
--card-foreground: oklch(0.97 0 0);
--popover: oklch(0.13 0.006 260);
--popover-foreground: oklch(0.97 0 0);
--primary: oklch(0.82 0.02 260);
--primary-foreground: oklch(0.12 0.015 260);
--secondary: oklch(0.20 0.006 260);
--secondary-foreground: oklch(0.97 0 0);
--muted: oklch(0.20 0.006 260);
--muted-foreground: oklch(0.62 0.006 260);
--accent: oklch(0.20 0.006 260);
--accent-foreground: oklch(0.97 0 0);
--destructive: oklch(0.55 0.22 25);
--border: oklch(0.25 0.006 260);
--input: oklch(0.25 0.006 260);
--ring: oklch(0.55 0.015 260);
}Dark mode
Nexus UI applies dark mode via a .dark class on the <html> element (not the media strategy). Register the custom variant once in your globals, right after the Tailwind import (shadcn init adds this line for you):
@import "tailwindcss";
@custom-variant dark (&:is(.dark *));Then toggle dark on <html> via your theme provider (next-themes or a custom script).
.dark to the wrapperMaya Chen
Design engineer
Components shipped
128- <div /* card */bg-whitedark:bg-zinc-900 (in effect)text-zinc-900dark:text-zinc-50 (in effect)ring-zinc-200dark:ring-zinc-800 (in effect)
- <span /* avatar */bg-zinc-100dark:bg-zinc-800 (in effect)text-zinc-700dark:text-zinc-200 (in effect)
- <p /* subtitle */text-zinc-500dark:text-zinc-400 (in effect)
- <strong /* stat */text-blue-600dark:text-blue-400 (in effect)
- <button /* button */bg-zinc-900dark:bg-white (in effect)text-whitedark:text-zinc-900 (in effect)
What Tailwind generates
Selector matches.dark\:bg-zinc-900:is(.dark *) {
background-color: var(--color-zinc-900);
}:is(.dark *) matches any element inside something with the dark class. Add it to one wrapper and every dark: utility below it switches at once. This demo keys the same selector to its own wrapper so the page's theme stays out.
Check it works
npm run devOpen http://localhost:3000 and add a class such as bg-primary text-primary-foreground to any element; it should pick up the colours from your tokens. Next, set up the cn() utility helper that components use to merge class names.
Why Tailwind v4?
Nexus UI is built entirely on Tailwind v4. Here is what changed and why it matters:
- —No tailwind.config.js — All configuration lives in CSS — no JavaScript config file needed.
- —CSS-first tokens — @theme inline maps CSS variables directly to utilities like bg-primary and text-foreground.
- —OKLCH colors — Perceptually uniform color space — light and dark tokens stay consistent across hue and brightness.
- —PostCSS plugin only — @tailwindcss/postcss replaces the old tailwindcss + autoprefixer pair.
- —Native CSS layers — Tailwind v4 uses @layer internally, giving you cleaner cascade control with no extra config.
- —Faster builds — The new Rust-based engine makes cold builds and incremental compiles significantly faster.