The accent-color CSS property allows the page to specify a color used by form controls instead of using the builtin default color. For example, "accent-color: red" on an <input type=checkbox> would change the blue color around the checkmark to red.
If this is not implemented by other browsers, then form controls will still work the same, they just won't have the custom accent-color.
Contact emails
jar...@chromium.orgExplainer
https://drafts.csswg.org/css-ui-4/#widget-accentSpecification
https://drafts.csswg.org/css-ui-4/#widget-accentAPI spec
YesSummary
The accent-color CSS property allows the page to specify a color used by form controls instead of using the builtin default color. For example, "accent-color: red" on an <input type=checkbox> would change the blue color around the checkmark to red.
Blink component
Blink>CSSTAG review
None, this has already been approved by the CSSWG
TAG review status
Not applicableRisks
Interoperability and Compatibility
If this is not implemented by other browsers, then form controls will still work the same, they just won't have the custom accent-color.
Gecko: In development (https://bugzilla.mozilla.org/show_bug.cgi?id=1705605)
WebKit: No signal (https://lists.webkit.org/pipermail/webkit-dev/2021-June/031885.html)
Web developers: Positive https://twitter.com/argyleink/status/1360022120810483715 https://bugs.chromium.org/p/chromium/issues/detail?id=1092093 has 26 stars https://bugs.chromium.org/p/chromium/issues/detail?id=1091531 has 17 stars complaining about the new forced blue color which this feature addresses
Is this feature fully tested by web-platform-tests?
YesTracking bug
https://bugs.chromium.org/p/chromium/issues/detail?id=1092093Launch bug
https://bugs.chromium.org/p/chromium/issues/detail?id=1193835Link to entry on the Chrome Platform Status
https://chromestatus.com/feature/4752739957473280Links to previous Intent discussions
Intent to prototype: https://groups.google.com/a/chromium.org/g/blink-dev/c/q9zf-frdewo/m/zxw2HuzGAQAJThis intent message was generated by Chrome Platform Status.
--
You received this message because you are subscribed to the Google Groups "blink-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to blink-dev+...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/blink-dev/CAK6btwKRHr0arTSU6sTq_nLGrf4oxw9g-8YCMB38Yk7EeZDKSg%40mail.gmail.com.
To unsubscribe from this group and stop receiving emails from it, send an email to blink-dev+...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/blink-dev/aabe9f68-6df3-01ab-e5d2-372ef19e4492%40mozilla.com.
> Also there are just a few tests, I guess this is something tricky to> test in WPT. Anyway should we check it applies to more elements than
> just checkbox?I have a bunch of pixel tests internal to chromium here. As for which elements it applies to, I think this might vary between browsers and isn't specified by the spec. For example, WebKit already uses the MacOS system preferences accent color setting to color checkboxes and radios, but it does not do the same for <input type=range> and <progress> like I implemented in Chromium. I could easily imagine WebKit implementing this for checkboxes and radios but nothing else, and again, the spec doesn't say... there may have been more discussion about this in spec issues and CSSWG that I missed though.
Emilio's comments about interop make me feel like maybe we should specify which elements it applies to though, even if WebKit doesn't end up implementing all of them...? I'm open to suggestions here.
> I don't think that's a great way to go around it, as choosing slightly> different colors dramatically changes the appearance of the controls. It
> feels also weird that accent-color would "trump" the color-scheme property.
> As implemented right now in Chromium and Gecko, some websites would have> pretty different form controls depending on which accent color is
> chosen, because we have different thresholds in order to consider
> something having little contrast, and Chrome auto-switches to dark mode
> controls if that happens (while Firefox just chooses a
> better-contrasting foreground color).
> an email to blink-dev+unsubscribe@chromium.org
> <mailto:blink-dev+unsubscribe@chromium.org>.
> To view this discussion on the web visit
> https://groups.google.com/a/chromium.org/d/msgid/blink-dev/CAK6btwKRHr0arTSU6sTq_nLGrf4oxw9g-8YCMB38Yk7EeZDKSg%40mail.gmail.com
> <https://groups.google.com/a/chromium.org/d/msgid/blink-dev/CAK6btwKRHr0arTSU6sTq_nLGrf4oxw9g-8YCMB38Yk7EeZDKSg%40mail.gmail.com?utm_medium=email&utm_source=footer>.
--
You received this message because you are subscribed to the Google Groups "blink-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to blink-dev+unsubscribe@chromium.org.
So the way form controls are drawn on Firefox requires two colors, a
"background" color (the accent color), and a "foreground" color (a color
that has sufficient contrast with the accent color). All other
decorative colors are derived from the accent color, by tweaking the
luminance.
For native form controls, the foreground and background colors are
provided by the OS (the macOS accent color, the Linux theme accent
color, etc). On Windows and Android it's hard-coded to white-on-blue,
though you can use the OS accent color if you change
`widget.non-native-theme.use-theme-accent` to true).
For the accent-color property, as specified it only requires one color
(the accent color), so we just choose a white or black foreground
depending on whether the color is "dark enough":
https://searchfox.org/mozilla-central/rev/2c991232499e826e46f9d976eb653817340ba389/widget/nsNativeBasicTheme.cpp#192-197
Note that we always blend the accent color with white to make sure it's
opaque.
Anyhow, I think the current approach is not great, but is as good as it
can get with only one color. I think it's slightly unfortunate as some
accent colors would still look better with white, and the authors could
want e.g., a checkmark that isn't white or black. That's why I think the
option of providing two colors (background and foreground) to the
property is best.
Thanks for the explanation and link to the code. That's super helpful. It looks like the Gecko approach is actually quite similar to the Chromium one. The IsDarkColor() function just looks at the equal-weighted average of raw RGB components and decides "dark" if it is <0.5. And then it uses pure white or pure black as the contrasting color. The Chromium approach differs in two ways. As Joey said, we use UX-picked "dark" and "light" colors, which are close to black/white, but not identical. And it actually computes the proper contrast ratio between the accent color and each of these colors, to ensure we get the maximum contrast choice, rather than just using averaged RGB components.
LGTM2
/Daniel
--
You received this message because you are subscribed to the Google Groups "blink-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to blink-dev+...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/blink-dev/9a27ab88-da84-4f3c-9184-37540d381a1bn%40chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/blink-dev/bcca7c09-9632-9164-ac86-f92a54498de2%40gmail.com.