Open josepharhar opened 1 month ago
I would prefer punting this until we've discussed general design principles for appearance: base
in #10866 which would influence this issue somewhat. I really believe thinking about this holistically aside outside of just one single form control is important to not repeat mistakes that were previously done.
Some feedback:
select::picker(select)
-> ::picker(select)
::picker()
probably shouldn't include a box-shadowappearance: base
across the board, since in 100% of the cases, people want to override itappearance: base
should probably just inherit the font for all controls since a custom font probably one of the annoying defaults for form controls.The last 2 points somewhat link to #10866 , and it might be good to discuss this in person at TPAC to find a set of consistent approaches to make this work holistically across all controls. We have many more ideas that are not covered by this comment alone
I would prefer punting this until we've discussed general design principles for
appearance: base
in #10866 which would influence this issue somewhat. I really believe thinking about this holistically aside outside of just one single form control is important to not repeat mistakes that were previously done.
Love this approach, by the way. I think it's a great idea to set down some guiding principles that we can refer back to as we design all of the controls. I added a few comments on https://github.com/w3c/csswg-drafts/issues/10866#issuecomment-2350130260.
- The checkmark icon deserves its own pseudo (::check? maybe, something that's reusable with for checkbox/radios)
Makes sense. We were fairly conflicted on the use of ::before
. One possibility is ::marker
but that's got other restrictions that might not make sense for <select>
use cases. So maybe ::check
or ::checkmark
.
- The dropdown icon deserves its own pseudo (::select-arrow? not super convinced by the name myself, but 🤷 )
Makes sense.
select::picker(select)
->::picker(select)
Agree.
- Styles should be minimal:
::picker()
probably shouldn't include a box-shadow
Likely fine, though the drop-shadow does help users distinguish that this is a popover picker "above" the in-page display. Perhaps we could find a less opinionated set of values?
- There's a lot of uses of system colors, I know that's prior art, but we're thinking of dropping that for
appearance: base
across the board, since in 100% of the cases, people want to override it
The really nice thing about system colors, though, is that they handle dark mode. We believe the defaults for all controls should work well in both light and dark mode. Instead of system colors, we could use light-dark()
but that just feels like more work for not much benefit, when the system colors do that already.
- There's use of custom fonts, we're also thinking
appearance: base
should probably just inherit the font for all controls since a custom font probably one of the annoying defaults for form controls.
Makes sense, and agree with the annoying defaults comment.
One possibility is ::marker but that's got other restrictions that might not make sense for
<select>
use cases.
::marker
is linked to display: list-item;
so unless we want to make <option>
element list-items, I'm not sure it's appropriate. Maybe @fantasai has opinions here :)
The really nice thing about system colors, though, is that they handle dark mode. We believe the defaults for all controls should work well in both light and dark mode. Instead of system colors, we could use light-dark() but that just feels like more work for not much benefit, when the system colors do that already.
There are alternatives that work in dark mode that don't involve light-dark() / system colors, while allowing easy overrides. We can probably discuss this in person at TPAC.
Colours chosen have other configs to potentially account for such as contrast preferences. One other benefit of system colours beyond just light and dark is they automatically adjust when using forced colors mode too. While it's likely to be overridden in most cases, it's possible that base appearance is used in a CSS reset but not actively overridden and imo (though others may disagree) we should make the default base styles as accessible and usable as possible, while maintaining the customisability.
As mentioned though there's alternatives to system colours.
The checkmark icon deserves its own pseudo (::check? maybe, something that's reusable with for checkbox/radios)
Could you elaborate on why this is? I don't necessarily object to having a specialized pseudo-element, but the reason we've avoided using ::before/::after in the past for CSS-defined things is the potential for it to conflict with existing author-provided code using those pseudos. That isn't the case here - these are brand new elements, impossible to target by any existing CSS no matter how general.
The checkmark icon deserves its own pseudo (::check? maybe, something that's reusable with for checkbox/radios)
Could you elaborate on why this is? I don't necessarily object to having a specialized pseudo-element, but the reason we've avoided using ::before/::after in the past for CSS-defined things is the potential for it to conflict with existing author-provided code using those pseudos. That isn't the case here - these are brand new elements, impossible to target by any existing CSS no matter how general.
The developer might choose ::before / ::after to do something else with it (add emojis? fancy selected option indicator? add a counter?), if they find out they need to override the default UA stylesheet usage, it's not really a great experience.
Thanks for the discussion! I created separate issues for pseudo-elements and colors:
There's use of custom fonts, we're also thinking appearance: base should probably just inherit the font for all controls since a custom font probably one of the annoying defaults for form controls.
So should we set all of the font longhands to inherit
? Or initial
or another special value? What is "the font for all controls"?
Set the font properties to unset
if you need to; they inherit by default, so ideally just leave them alone.
The CSS Working Group just discussed [css-ui] UA stylesheet for appearance:base `<select>`
, and agreed to the following:
RESOLVED: font properties won't be set in the UA style sheet
I took @nt1m's styles from webkit for buttons and put them in the OP, as well as our last resolution on inheriting fonts.
Based on the discussions so far, it sounds like we probably shouldn't have a box shadow, so I am removing that from the proposed styles in the OP. I'm also replacing ::before and ::after with ::check and ::select-arrow
I'd like to propose a UA stylesheet for
<select>
which applies when the<select>
hassize=1
, nomultiple
attribute, andappearance:base
.Based on the discussion here and the proof of concept in the chromium prototype I implemented, we can make these styles only apply when
<select>
hasappearance:base
.