A technique for using CSS contrast-color() to manipulate button hover states by adjusting lightness rather than mixing black or white. By interpolating contrast-color() into a numeric value (1 or -1) via CSS if() statements and @property, you can use oklch() relative color syntax to lighten or darken a color along its natural lightness ramp. This produces warmer, more harmonious hover states compared to color-mix() with black/white, and offers finer control over the step amount and even chroma adjustments.

3m read timeFrom daverupert.com
Post cover image

Sort: