Assembling Future Palette

Let's create a system where changing just ONE variable will recolor the entire site, observing contrast and harmony rules.

:root {
  /* Base shade (Hue) */
  --theme-h: 250; 
  
  /* Generate main colors */
  --primary: oklch(60% 0.15 var(--theme-h));
  --surface: oklch(98% 0.01 var(--theme-h));
  --text:    oklch(20% 0.05 var(--theme-h));
  
  /* Automatic accent for buttons (mix with blue for brightness) */
  --accent: color-mix(in oklch, var(--primary), white 40%);
}

.button {
  background: var(--primary);
  color: white;
  transition: background 0.3s;
}

.button:hover {
  background: var(--accent);
}

What's the Advantage of This Code?

  • Consistency: All colors have same " base " shade, making design cohesive.
  • Scalability: Want to change theme from blue to green? Just change --theme-h: 150;.
  • Contrast: Since we use oklch, we're confident color brightness will be predictable on any screen.
Tip

Add @media (prefers-color-scheme: dark) to this, and you'll get a full dark theme in a couple of lines!