ui

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, radius, and shadow is a design token 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.

All values use HSL format (hue saturation% lightness%) so Tailwind's opacity modifier utilities work automatically — text-primary/50, bg-primary/10, etc.

Default Color Scale (Zinc)

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

Or add it manually to your globals.css:

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

Add a .dark class to your <html> element and define the dark-mode values:

Using next-themes

For Next.js, next-themes handles system preference detection and toggling:

Wrap your root layout:

Custom Themes

Override any subset of variables to create a custom palette. Here's a blue-focused theme:

Everything you don't override falls back to the zinc defaults.

Border Radius

The --radius variable drives the global radius scale. Components use calculated offsets (calc(var(--radius) - 2px) for inner elements) so the whole UI scales together:

Per-Component Overrides

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

Variable Reference