Skip to content

[css-forms-1] Improve slider UA styles #12427

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 33 additions & 2 deletions css-forms-1/Overview.bs
Original file line number Diff line number Diff line change
Expand Up @@ -813,11 +813,31 @@ select {

## Sliders ## {#stylesheet-sliders}

ISSUE: Refine meter, progress, switch and range input styling.
ISSUE(12267): Refine meter, progress, switch and range input styling.

```css
input:is([type=checkbox][switch], [type=range]) {
display: inline-flex;
position: relative;
align-items: center;
width: 100%;
}

input[type=checkbox][switch] {
width: 2em;
}

::slider-track {
height: 1em;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably need some thought on how to meet WCAG target sizing here. Same goes for existing checkbox styling I believe.

width: 100%;
}

input[type=range]::slider-track {
height: 0.5em;
}

input[type=checkbox][switch]::slider-track {
border-radius: 1em;
}

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

input[type=checkbox][switch]::slider-fill {
background-color: transparent;
border-radius: inherit;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not really sure if this should be needed, for my range input prototype it isn't but for switch it seems to be else the fill overflows the track.

We can adjust accordingly in future if it's not needed.

}

::slider-thumb {
border-radius: 0;
border: none;
background-color: currentColor;
appearance: none;
width: 1em;
height: 100%;
height: 1em;
border-radius: 100%;
position: absolute;
}

input[type=checkbox][switch]:checked::slider-thumb {
inset-inline-end: 0;
}
```

Expand Down