8000 [css-color-5] add target contrast ratio to color-contrast? · Issue #4749 · w3c/csswg-drafts · GitHub
[go: up one dir, main page]

Skip to content

[css-color-5] add target contrast ratio to color-contrast? #4749

@svgeesus

Description

@svgeesus

@mirisuzanne wrote

I like the basic thrust, but working on design systems, I often need more control than max-contrast from a list. I’d like to see these uses considered as well:

* min contrast to meet a particular ratio (from list)
* adjust given color to meet a particular ratio

I imagine the latter may open up too much complexity - but I’d consider the former a primary use-case.

Currently, the color-contrast() function takes two arguments: a color, and a list of colors.

This requirement could be addressed by adding a third parameter, which is a target contrast ratio. Instead of comparing the whole list, comparisons stop once the target contrast ratio has been reached or exceeded.

This assumes that the list is in order of desirability, but the resolution of #4732 already implies this (if two colors in the list have the same contrast, the earlier in the list wins; this implies the stylesheet author put them in order of desirability).

color-contrast() = color-contrast( <color>  <color>#  number?)

The number is optional and if omitted, the whole list is searched to fi 644D nd the highest contrast ratio.

So for example

color-contrast(tan var(--blue1), var(--blue2), var(--blue3), var(--blue4) 4.5)

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    0