Skip to content

Commit 6371aaf

Browse files
committed
[css-forms-1] Add improved slider UA styles styles for switch
Positioning of ::slider-thumb and sizing of ::slider-fill for range still need to be added.
1 parent ba60227 commit 6371aaf

File tree

1 file changed

+30
-2
lines changed

1 file changed

+30
-2
lines changed

css-forms-1/Overview.bs

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -837,14 +837,31 @@ select {
837837

838838
## Sliders ## {#stylesheet-sliders}
839839

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

842842
```css
843+
input[type="checkbox][switch],
844+
input[type="range"] {
845+
display: inline-flex;
846+
position: relative;
847+
align-items: center;
848+
width: 100%;
849+
}
850+
843851
input[type="checkbox"][switch]::slider-track,
844852
input[type="range"]::slider-track,
845853
meter::slider-track,
846854
progress::slider-track {
847855
height: 1em;
856+
width: 100%;
857+
}
858+
859+
input[type=range]::slider-track {
860+
height: 0.5em;
861+
}
862+
863+
input[type=checkbox][switch]::slider-track {
864+
border-radius: 1em;
848865
}
849866

850867
input[type="checkbox"][switch]::slider-fill,
@@ -859,14 +876,25 @@ progress:indeterminate::slider-fill {
859876
inline-size: 0;
860877
}
861878

879+
input[type=checkbox][switch]::slider-fill {
880+
background-color: transparent;
881+
border-radius: inherit;
882+
}
883+
862884
input[type="checkbox"][switch]::slider-thumb,
863885
input[type="range"]::slider-thumb {
864886
border-radius: 0;
865887
border: none;
866888
background-color: currentColor;
867889
appearance: none;
868890
width: 1em;
869-
height: 100%;
891+
height: 1em;
892+
border-radius: 100%;
893+
position: absolute;
894+
}
895+
896+
input[type=checkbox][switch]:checked::slider-thumb {
897+
inset-inline-end: 0;
870898
}
871899
```
872900

0 commit comments

Comments
 (0)