Skip to content

Commit 6ca38b5

Browse files
authored
[css-forms-1] Improve slider UA styles (#12427)
* [css-forms-1] Add improved slider UA styles Positioning of ::slider-thumb and sizing of ::slider-fill for range still need to be added.
1 parent 4f1d355 commit 6ca38b5

File tree

1 file changed

+44
-5
lines changed

1 file changed

+44
-5
lines changed

css-forms-1/Overview.bs

Lines changed: 44 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -842,36 +842,75 @@ select {
842842

843843
## Sliders ## {#stylesheet-sliders}
844844

845-
ISSUE: Refine meter, progress, switch and range input styling.
845+
ISSUE(12267): Refine meter, progress, switch and range input styling.
846846

847847
```css
848+
input[type="checkbox][switch],
849+
input[type="range"] {
850+
display: inline-flex;
851+
position: relative;
852+
align-items: center;
853+
inline-size: 100%;
854+
}
855+
848856
input[type="checkbox"][switch]::slider-track,
849857
input[type="range"]::slider-track,
850858
meter::slider-track,
851859
progress::slider-track {
852-
height: 1em;
860+
block-size: 1em;
861+
inline-size: 100%;
862+
}
863+
864+
input[type=range]::slider-track {
865+
block-size: 0.5em;
866+
}
867+
868+
input[type=checkbox][switch]::slider-track {
869+
border-radius: 1em;
853870
}
854871

855872
input[type="checkbox"][switch]::slider-fill,
856873
input[type="range"]::slider-fill,
857874
meter::slider-fill,
858875
progress::slider-fill {
859-
height: 100%;
876+
block-size: 100%;
860877
background-color: currentColor;
861878
}
862879

863880
progress:indeterminate::slider-fill {
864881
inline-size: 0;
865882
}
866883

884+
input[type="range"]::slider-fill,
885+
input[type=checkbox][switch]::slider-fill {
886+
background-color: color-mix(currentColor 25%, transparent);
887+
border-radius: inherit;
888+
889+
block-size: 100%;
890+
}
891+
892+
input[type=checkbox][switch]::slider-fill {
893+
inline-size: 0%;
894+
}
895+
896+
input[type="checkbox"][switch]:checked::slider-fill {
897+
inline-size: 100%;
898+
}
899+
867900
input[type="checkbox"][switch]::slider-thumb,
868901
input[type="range"]::slider-thumb {
869902
border-radius: 0;
870903
border: none;
871904
background-color: currentColor;
872905
appearance: none;
873-
width: 1em;
874-
height: 100%;
906+
inline-size: 1em;
907+
block-size: 1em;
908+
border-radius: 100%;
909+
position: absolute;
910+
}
911+
912+
input[type=checkbox][switch]:checked::slider-thumb {
913+
inset-inline-end: 0;
875914
}
876915
```
877916

0 commit comments

Comments
 (0)