Skip to content

Commit da4f5d2

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 31df7a5 commit da4f5d2

File tree

1 file changed

+33
-2
lines changed

1 file changed

+33
-2
lines changed

‎css-forms-1/Overview.bs

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -813,11 +813,31 @@ select {
813813

814814
## Sliders ## {#stylesheet-sliders}
815815

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

818818
```css
819+
input:is([type=checkbox][switch], [type=range]) {
820+
display: inline-flex;
821+
position: relative;
822+
align-items: center;
823+
width: 100%;
824+
}
825+
826+
input[type=checkbox][switch] {
827+
width: 2em;
828+
}
829+
819830
::slider-track {
820831
height: 1em;
832+
width: 100%;
833+
}
834+
835+
input[type=range]::slider-track {
836+
height: 0.5em;
837+
}
838+
839+
input[type=checkbox][switch]::slider-track {
840+
border-radius: 1em;
821841
}
822842

823843
::slider-fill {
@@ -829,13 +849,24 @@ ISSUE: Refine meter, progress, switch and range input styling.
829849
inline-size: 0;
830850
}
831851

852+
input[type=checkbox][switch]::slider-fill {
853+
background-color: transparent;
854+
border-radius: inherit;
855+
}
856+
832857
::slider-thumb {
833858
border-radius: 0;
834859
border: none;
835860
background-color: currentColor;
836861
appearance: none;
837862
width: 1em;
838-
height: 100%;
863+
height: 1em;
864+
border-radius: 100%;
865+
position: absolute;
866+
}
867+
868+
input[type=checkbox][switch]:checked::slider-thumb {
869+
inset-inline-end: 0;
839870
}
840871
```
841872

0 commit comments

Comments
 (0)