Define and use theme variables with @theme directive, oklch() color format, semantic naming, and namespaced utilities. Use when customizing design tokens or creating design systems.
Defines custom design tokens using @theme directive with oklch() colors and semantic naming.
/plugin marketplace add djankies/claude-configs/plugin install tailwind-4@claude-configsThis skill is limited to using the following tools:
references/color-conversion.mdreferences/namespace-reference.mdDefine custom design tokens using the @theme directive with CSS variables. Tailwind v4 uses modern color formats (oklch) and namespace-based utility generation.
@import 'tailwindcss';
@theme {
--font-display: 'Satoshi', 'sans-serif';
--font-body: 'Inter', 'sans-serif';
--color-brand-primary: oklch(0.65 0.25 270);
--color-brand-accent: oklch(0.75 0.22 320);
--breakpoint-3xl: 120rem;
--breakpoint-4xl: 160rem;
--spacing-18: 4.5rem;
--spacing-72: 18rem;
--radius-4xl: 2rem;
--shadow-brutal: 8px 8px 0 0 rgb(0 0 0);
}
Tailwind v4 uses OkLCh color space instead of RGB for wider gamut and more vivid colors on modern displays.
oklch() syntax:
oklch(Lightness Chroma Hue)
Examples:
@theme {
--color-blue: oklch(0.65 0.25 270);
--color-green: oklch(0.72 0.15 142);
--color-red: oklch(0.65 0.22 25);
--color-purple: oklch(0.75 0.22 320);
--color-orange: oklch(0.78 0.18 60);
}
Tailwind generates utilities based on variable name prefixes:
| Namespace | Utilities Generated |
|---|---|
--color-* | bg-, text-, fill-, stroke-, border-, ring- |
--font-* | font-family utilities |
--text-* | font-size utilities |
--font-weight-* | font-weight utilities |
--tracking-* | letter-spacing utilities |
--leading-* | line-height utilities |
--breakpoint-* | responsive breakpoint variants |
--spacing-* | padding, margin, sizing utilities |
--radius-* | border-radius utilities |
--shadow-* | box-shadow utilities |
--animate-* | animation utilities |
Example usage:
@theme {
--color-brand: oklch(0.65 0.25 270);
--spacing-18: 4.5rem;
--radius-4xl: 2rem;
}
Generates utilities:
<div class="bg-brand text-brand border-brand"></div>
<div class="p-18 m-18 w-18"></div>
<div class="rounded-4xl"></div>
Use meaningful names instead of generic scales:
@theme {
--color-primary: oklch(0.65 0.25 270);
--color-secondary: oklch(0.75 0.22 320);
--color-success: oklch(0.72 0.15 142);
--color-warning: oklch(0.78 0.18 60);
--color-error: oklch(0.65 0.22 25);
--color-text: oklch(0.21 0 0);
--color-text-muted: oklch(0.51 0 0);
--color-background: oklch(0.99 0 0);
}
Usage:
<button class="bg-primary text-white hover:opacity-90">Primary Button</button>
<div class="text-error">Error message</div>
<p class="text-text-muted">Muted text</p>
Add new values without removing defaults:
@theme {
--color-lagoon: oklch(0.72 0.11 221.19);
--color-coral: oklch(0.74 0.17 40.24);
--font-script: 'Great Vibes', cursive;
--breakpoint-3xl: 120rem;
}
All default Tailwind utilities remain available (blue-500, gray-200, etc.).
Remove all defaults and define only custom variables:
@theme {
--*: initial;
--spacing: 4px;
--font-body: 'Inter', sans-serif;
--color-lagoon: oklch(0.72 0.11 221.19);
--color-coral: oklch(0.74 0.17 40.24);
}
Only utilities based on custom variables will be generated.
Reference other variables using the inline option:
@theme inline {
--font-sans: var(--font-inter);
--color-primary: var(--color-red-500);
--spacing-gutter: var(--spacing-4);
}
Variables defined in @theme inline can reference variables from main @theme.
Generate all CSS variables even if unused:
@theme static {
--color-primary: var(--color-red-500);
--color-secondary: var(--color-blue-500);
}
Useful for runtime JavaScript access:
const styles = getComputedStyle(document.documentElement);
const primaryColor = styles.getPropertyValue('--color-primary');
const styles = getComputedStyle(document.documentElement);
const shadow = styles.getPropertyValue('--shadow-xl');
const color = styles.getPropertyValue('--color-blue-500');
Setting variables dynamically:
document.documentElement.style.setProperty('--color-primary', 'oklch(0.70 0.20 180)');
In animation libraries:
<motion.div animate={{ backgroundColor: 'var(--color-blue-500)' }} />
Create shared theme file:
packages/brand/theme.css:
@theme {
--*: initial;
--spacing: 4px;
--font-body: 'Inter', sans-serif;
--color-lagoon: oklch(0.72 0.11 221.19);
--color-coral: oklch(0.74 0.17 40.24);
}
Import in projects:
@import 'tailwindcss';
@import '@my-company/brand/theme.css';
@import 'tailwindcss';
@theme {
--font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
--font-mono: 'JetBrains Mono', 'Fira Code', monospace;
--text-xs: 0.75rem;
--text-sm: 0.875rem;
--text-base: 1rem;
--text-lg: 1.125rem;
--text-xl: 1.25rem;
--color-white: #ffffff;
--color-black: #000000;
--color-gray-50: oklch(0.99 0 0);
--color-gray-100: oklch(0.97 0 0);
--color-gray-900: oklch(0.21 0 0);
--color-primary: oklch(0.65 0.25 270);
--color-secondary: oklch(0.75 0.22 320);
--color-success: oklch(0.72 0.15 142);
--spacing: 0.25rem;
--spacing-px: 1px;
--spacing-1: calc(var(--spacing) * 1);
--spacing-4: calc(var(--spacing) * 4);
--radius-md: 0.375rem;
--radius-lg: 0.5rem;
--radius-full: 9999px;
--shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1);
--shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1);
--breakpoint-sm: 40rem;
--breakpoint-md: 48rem;
--breakpoint-lg: 64rem;
}
This skill should be used when the user asks to "create a hookify rule", "write a hook rule", "configure hookify", "add a hookify rule", or needs guidance on hookify rule syntax and patterns.
Create distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.