The CSS contrast-color() function only returns black or white, which is limiting for design systems that need brand-specific colors. Using Lea Verou's --contrast-color() workaround alongside the upcoming CSS if() function, you can map contrast results to your own design tokens. The technique requires registering a custom property with @property to enable color-type comparisons in style queries, then using an if() statement to select the appropriate design system token based on whether the contrast result is light or dark.

3m read timeFrom daverupert.com
Post cover image

Sort: