A walkthrough of building a user-customizable white-label theme system using Tailwind CSS v4 and the OKLCH color space. The technique generates an entire 11-shade color palette from a single CSS variable (--color-value representing the hue angle), so changing one value recolors the entire app instantly. The setup uses Tailwind's @theme directive with OKLCH color functions, a data-theme style tag in the HTML layout for the default value, and a small Stimulus controller that updates the CSS variable at runtime via a range slider. OKLCH is highlighted as ideal for palette generation because lightness and chroma stay consistent across shades while only the hue changes.

Table of contents
OKLCH?Setting up the HTMLWiring up the theme controllerThe demo interfaceUser-selected themes67.8K Impressions6 Comments