[csswg-drafts] [css-forms-1] For `control-value()` to be useful it needs a way to convert to other types. (#11842)

lukewarlow has just created a new issue for https://github.com/w3c/csswg-drafts:

== [css-forms-1] For `control-value()` to be useful it needs a way to convert to other types. ==
Currently CSS Forms defines `control-value()` to be able to return a string or number, but for this to be useful we would need a way to convert to other CSS types (https://github.com/w3c/csswg-drafts/issues/6408 ?).

Take `<progress>` as an example, it has a value between 0 and 100. This is useful for sizing the fill portion of the control, but for that we'd need a way to make it a (percentage) length instead.

```css
progress::fill {
    inline-size: convert(content-value("<number>"), "<length>", "%");
}
```

Alternatively if we could pass other types into `content-value()` and the browser could do the conversion for us that'd also work?

```css
progress::fill {
    inline-size: content-value("<length>", "%");
}
```

Either of these could also help with styling the color input too (along with #11837 )

The default style could be something like:

```css
input[type=color]::color-swatch {
     background-color: content-value("<color>"); /* or convert(content-value(), "<color>") */
}
```

Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/11842 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Wednesday, 5 March 2025 20:30:30 UTC