cnippet/ui
  1. docs
  2. theming

guides

Theming

Customize colors, radius, and dark mode with CSS variables and Tailwind CSS v4.

cnippet ui uses a CSS variables-based theming system built on Tailwind CSS v4. Every color and the radius are design tokens you can override — globally or scoped to a single component.

How It Works

Components reference semantic CSS variables (--primary, --muted, --border, etc.) rather than hard-coded values. Changing a variable updates every component that references it.

app/globals.css

Tokens point at the Tailwind CSS palette, mixes of it (color-mix()) or translucent black and white (--alpha()). An @theme inline block turns each token into Tailwind utilities, so --primary gives you bg-primary, text-primary and opacity modifiers like bg-primary/10:

app/globals.css

Default Colors

The default palette is neutral-based. Install it with the CLI:

Colors shows every token with its light and dark value, and has the full CSS to copy. Manual Installation has the complete stylesheet, including the @theme inline mappings.

Extended Tokens

cnippet ui adds semantic tokens for feedback states not covered by the base shadcn/ui scale:

These are consumed by <Alert>, <Badge>, and <Toast> when using variant="info", "success", or "warning".

Dark Mode

Every token has a second value in a .dark block. Adding the dark class to <html> switches every component to those values.

Dark Mode covers setup for Next.js, Vite, React Router, TanStack Start and Astro, a theme toggle, and how to avoid a flash of the wrong theme.

Custom Themes

Override any subset of variables to create a custom palette. Set both the light and the dark value. Here's a blue-focused theme:

Everything you don't override falls back to the defaults. You can also use any CSS color, such as oklch(0.55 0.2 260) or #2563eb.

Border Radius

The --radius variable drives the global radius scale. The rounded-sm, rounded-md, rounded-lg and rounded-xl utilities are calculated from it, so the whole UI scales together:

Per-Component Overrides

For variants, data attributes and wrapper components, see Customization.

Because components are copied into your project, you can scope token overrides with inline styles:

Or set tokens on a class and apply it to a section:

Variable Reference

Colors lists every color token with its light and dark value, grouped by purpose: surfaces, actions, status, lines, charts, sidebar and code.