Skip to content

Commit 87ca031

Browse files
authored
[css-forms] Add select list box styles (#12908)
1 parent 01d6cc6 commit 87ca031

File tree

1 file changed

+40
-15
lines changed

1 file changed

+40
-15
lines changed

css-forms-1/Overview.bs

Lines changed: 40 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -895,14 +895,12 @@ input[type=radio]:checked::checkmark {
895895
width: 100%;
896896
}
897897
```
898-
## Selects & buttons ## {#stylesheet-select-button}
899898

900-
```css
901-
select {
902-
/* Base appearance select always sizes based on its contents. */
903-
field-sizing: content !important;
904-
}
899+
## Buttons (and button-like controls) ## {#stylesheet-button}
900+
901+
Selects are only button-like when they're a [drop-down box](https://html.spec.whatwg.org/multipage/rendering.html#drop-down-box).
905902

903+
```css
906904
button,
907905
::file-selector-button,
908906
select,
@@ -953,17 +951,11 @@ input:is([type="color"], [type="button"], [type="reset"], [type="submit"]) {
953951
:disabled::file-selector-button {
954952
color: color-mix(in srgb, currentColor 50%, transparent);
955953
}
954+
```
956955

957-
select > button:first-child {
958-
/* Prevents button from setting font, color, or background-color */
959-
all: unset;
960-
961-
/* Prevents duplicate box decorations */
962-
display: contents;
956+
## Selects ## {#stylesheet-select}
963957

964-
/* Prevents button activation behavior so select can handle events */
965-
interactivity: inert !important;
966-
}
958+
```css
967959
select option {
968960
/* These min-size rules ensure accessibility by following WCAG rules:
969961
* https://www.w3.org/WAI/WCAG22/Understanding/target-size-minimum.html
@@ -1020,6 +1012,27 @@ select option {
10201012
/* this creates a full bleed hover highlight */
10211013
padding-inline: 0.5em;
10221014
}
1015+
```
1016+
1017+
### Drop-down box selects ### {#stylesheet-dropdown-select}
1018+
1019+
These styles should apply when the select is a [drop-down box](https://html.spec.whatwg.org/multipage/rendering.html#drop-down-box).
1020+
1021+
```css
1022+
select {
1023+
field-sizing: content !important;
1024+
}
1025+
1026+
select > button:first-child {
1027+
/* Prevents button from setting font, color, or background-color */
1028+
all: unset;
1029+
1030+
/* Prevents duplicate box decorations */
1031+
display: contents;
1032+
1033+
/* Prevents button activation behavior so select can handle events */
1034+
interactivity: inert !important;
1035+
}
10231036
10241037
select::picker-icon {
10251038
/* margin-inline-start pushes the icon to the right of the box */
@@ -1062,6 +1075,18 @@ select::picker-icon {
10621075
}
10631076
```
10641077
1078+
### List box selects ### {#stylesheet-listbox-select}
1079+
1080+
These styles should apply when the select is a [list box](https://html.spec.whatwg.org/multipage/rendering.html#list-box).
1081+
1082+
```css
1083+
select {
1084+
overflow: auto;
1085+
display: inline-block;
1086+
block-size: calc(max(24px, 1lh) * attr(size type(<integer>), 4));
1087+
}
1088+
```
1089+
10651090
<h2 class=no-num id=changes>Changes</h2>
10661091
10671092
<h3 class=no-num id=changes-20250325>Since the

0 commit comments

Comments
 (0)