Docs / Theming & Tailwind

Theming & Tailwind

Customize themes, CSS variables, and Tailwind CSS configuration for shadcn/ui blocks. Dark mode and color schemes.

Our blocks use the standard shadcn/ui theming system, which leverages CSS variables and Tailwind CSS. This means they work seamlessly with the official shadcn themes and popular theme editors.

Getting Started

Download our base globals.css file which includes all the CSS variables needed for shadcn/ui components:

Download globals.css

This file includes:

  • Light and dark mode color variables
  • Chart colors for data visualization
  • Sidebar-specific variables
  • Shadow and radius tokens
  • Font family definitions

CSS Variables

shadcn/ui components use CSS variables for theming. Here are the core variables:

Color Variables

VariableDescription
--backgroundPage background color
--foregroundDefault text color
--cardCard background
--card-foregroundCard text color
--popoverPopover/dropdown background
--popover-foregroundPopover text color
--primaryPrimary brand color
--primary-foregroundText on primary color
--secondarySecondary color
--secondary-foregroundText on secondary color
--mutedMuted/subtle backgrounds
--muted-foregroundMuted text color
--accentAccent color for highlights
--accent-foregroundText on accent color
--destructiveError/danger color
--borderBorder color
--inputInput border color
--ringFocus ring color

Chart Colors

For data visualization components:

VariableDescription
--chart-1 through --chart-5Chart color palette

For sidebar components:

VariableDescription
--sidebarSidebar background
--sidebar-foregroundSidebar text
--sidebar-primarySidebar primary accent
--sidebar-accentSidebar hover states
--sidebar-borderSidebar borders
--sidebar-ringSidebar focus rings

Other Tokens

VariableDescription
--radiusBase border radius (e.g., 8px)
--shadow-*Shadow tokens (2xs, xs, sm, md, lg, xl, 2xl)
--font-sansSans-serif font stack
--font-serifSerif font stack
--font-monoMonospace font stack

Dark Mode

Dark mode is handled via the .dark class on the <html> or <body> element. All color variables should have both light and dark variants:

:root {
  --background: oklch(1 0 0);
  --foreground: oklch(0.145 0 0);
}

.dark {
  --background: oklch(0.145 0 0);
  --foreground: oklch(0.985 0 0);
}

Color Formats

shadcn/ui supports multiple color formats:

  • OKLCH (recommended): oklch(0.145 0 0) - Better perceptual uniformity
  • HSL: hsl(0 0% 100%) - Traditional format
  • RGB: rgb(255 255 255) - Standard RGB

Our globals.css uses OKLCH for better color accuracy across light and dark modes.

Using Themes

Pre-made Themes

You can preview blocks with different themes directly on our site:

  • Blocks pages: Use the theme selector dropdown in the toolbar
  • Explorer: Use the Theme section in the right sidebar

When you download globals.css from the toolbar (click the Tailwind icon), it will include your selected theme’s color variables.

Theme Compatibility

Our blocks are compatible with themes from:

Simply copy the CSS variables from any of these tools into your globals.css.

Tailwind 4

Our blocks are built for Tailwind CSS v4. The key differences from v3:

CSS-First Configuration

Tailwind 4 uses CSS for configuration instead of tailwind.config.js:

@import "tailwindcss";

@theme inline {
  --color-background: var(--background);
  --color-foreground: var(--foreground);
  --color-primary: var(--primary);
  /* ... */
}

Dark Mode Variant

@custom-variant dark (&:where(.dark, .dark *));

Plugins

@plugin "@tailwindcss/typography";
@import "tw-animate-css";

Customizing Your Theme

Changing Colors

To customize your theme, modify the CSS variables in your globals.css:

:root {
  /* Change primary to a blue */
  --primary: oklch(0.5 0.2 250);
  --primary-foreground: oklch(0.98 0 0);
}

Changing Border Radius

Adjust the --radius variable to change the overall roundness:

:root {
  --radius: 4px;  /* Sharp corners */
  --radius: 8px;  /* Default */
  --radius: 12px; /* More rounded */
}

Adding Custom Fonts

  1. Import your fonts (via Google Fonts, local files, or next/font)
  2. Update the font variables:
:root {
  --font-sans: "Your Font", ui-sans-serif, system-ui, sans-serif;
  --font-display: "Your Display Font", sans-serif;
}

Animations

Our globals.css includes animation keyframes used by various components:

  • accordion-down / accordion-up - Accordion expand/collapse
  • fade-in - Fade in with slide
  • marquee / marquee-vertical - Infinite scroll animations
  • shimmer-slide - Loading shimmer effect
  • orbit - Orbital motion
  • aurora - Aurora background effect

These are defined in the @theme inline block and can be used with Tailwind’s animate-* utilities.

Next Steps