Skip to content

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

Merged
lukewarlow merged 2 commits intow3c:mainfrom
lukewarlow:initial-switch-styles
Mar 16, 2026
Merged

[css-forms-1] Improve slider UA styles#12427
lukewarlow merged 2 commits intow3c:mainfrom
lukewarlow:initial-switch-styles

Conversation

@lukewarlow
Copy link
Copy Markdown
Member

@lukewarlow lukewarlow commented Jul 1, 2025

See #12267

Still need to add stuff such as hover styles to this but this is the basics.

image

(Range Image includes an implementation of sizing for the fill, and positioning of the thumb which aren't included in this PR)

image

@lukewarlow lukewarlow requested a review from nt1m July 1, 2025 12:38
@lukewarlow lukewarlow force-pushed the initial-switch-styles branch 3 times, most recently from 7c2d3a6 to 6053ab4 Compare July 1, 2025 17:08

input[type=checkbox][switch]::slider-fill {
background-color: transparent;
border-radius: inherit;
Copy link
Copy Markdown
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-track {
height: 1em;
Copy link
Copy Markdown
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.

Copy link
Copy Markdown
Member

@nt1m nt1m left a comment

Choose a reason for hiding this comment

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

This looks good by itself, I do think we should do this at the same for other controls too though, it's very likely that range inputs (and potentially other slider based controls) end up looking similar in terms of border-radius.

Comment on lines +861 to +866
position: absolute;
}

input[type=checkbox][switch]:checked::slider-thumb {
inset-inline-end: 0;
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I wonder if we could use grid and align properties somehow here.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I suspect we'll still end up using absolute positioning for range inputs though. So it depends how much cleaner it actually is.

@lukewarlow
Copy link
Copy Markdown
Member Author

This looks good by itself, I do think we should do this at the same for other controls too though,

Okay I'll make this draft and merge my other PR into this one so it can all be judged together.

@lukewarlow lukewarlow marked this pull request as draft July 1, 2025 18:23
@lukewarlow lukewarlow changed the title [css-forms-1] Add initial UA styles for switch [css-forms-1] Improve slider UA styles Jul 1, 2025
@lukewarlow lukewarlow force-pushed the initial-switch-styles branch from 02fb20b to da4f5d2 Compare July 1, 2025 18:24
@lukewarlow lukewarlow force-pushed the initial-switch-styles branch from da4f5d2 to 6371aaf Compare January 26, 2026 22:26
@lukewarlow lukewarlow marked this pull request as ready for review February 18, 2026 10:54
@lukewarlow lukewarlow force-pushed the initial-switch-styles branch from f1d29cf to a62208c Compare March 3, 2026 20:28
@lukewarlow lukewarlow requested review from fantasai and nt1m March 3, 2026 20:28
Positioning of ::slider-thumb and sizing of ::slider-fill for range still need to be added.
@lukewarlow lukewarlow force-pushed the initial-switch-styles branch from a62208c to 8c4bb52 Compare March 3, 2026 21:02
@lukewarlow
Copy link
Copy Markdown
Member Author

@nt1m does this look good to merge? We'll obviously need follow-ups for stuff like WCAG touch sizing and actually positioning the thumbs and stuff.

@lukewarlow lukewarlow merged commit 6ca38b5 into w3c:main Mar 16, 2026
3 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants