Tailwind CSS v4 Color Architecture: OKLCH, @theme & Troubleshooting
As documented in the official Tailwind v4 documentation, Tailwind CSS v4 introduces a revolutionary paradigm shift. Configuration migrates away from JavaScript tailwind.config.js files to native CSS custom properties declared inside the Tailwind v4 globals CSS using the Tailwind v4 theme block.
Key architectural aspects of modern Theme Tailwind v4:
- OKLCH to HEX & Perceptual Uniformity: Tailwind v4 specifies all 22 default color families (242 tokens) in the
oklch()color space (CSS Color Module Level 4). Unlike legacy RGB or HSL, OKLCH guarantees consistent perceived lightness across different hues, so a500stop blue and yellow share equal visual weight. Our studio handles bidirectional OKLCH to HEX conversion and Tailwind colors rgba mapping, including base anchors like Tailwind white color (#FFFFFF). - Tailwind Colors Not Working: If you encounter tailwind colors not working during a v3 to v4 migration, ensure you have removed legacy Tailwind v4 config JS files, placed
@themeafter@import "tailwindcss";in your stylesheet, and registered custom variables properly. - Variables & Custom Variants: You can apply Tailwind CSS variables in className utilities (e.g.
bg-[var(--color-brand-500)]), generate a custom-variant Tailwind v4 utility, and declare custom Tailwind color variables seamlessly.
@theme {
--color-brand-500: oklch(0.58 0.23 278);
--color-brand-600: oklch(0.49 0.22 278);
}Our Tailwind theme generator allows you to copy official tailwind v4 color scale hex css, copy official tailwind v4 color scale hex html, and learn how to export tailwind color scale to css variables using 1-click token actions or how to export tailwind color scale to css variables javascript pipelines.