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

Conversation

lukewarlow
Copy link
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 and background color 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
@@ -829,6 +841,11 @@ 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.

align-items: center;
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.

Copy link
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 870
position: absolute;
}

input[type=checkbox][switch]:checked::slider-thumb {
inset-inline-end: 0;
}
Copy link
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
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
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 Jul 1, 2025
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 02fb20b to da4f5d2 Compare July 1, 2025 18:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
2 participants