Repository navigation
Open
Labels
a11y-trackerGroup bringing to attention of a11y, or tracked by the a11y Group but not needing response.Group bringing to attention of a11y, or tracked by the a11y Group but not needing response.accessibilityAffects accessibilityAffects accessibilityaddition/proposalNew features or enhancementsNew features or enhancementsstage: 1IncubationIncubationtopic: formstopic: rendering
Description
This is a feature request on the behalf of all web developers targeting mobile. Here are reasons the toggle switch element should be natively available in HTML forms:
- Switch is a standard and popular UI control in both Android and iOS mobile platforms.
- Checkbox is used in websites due to the absence of the switch. Checkbox is absent from iOS and is not considered a good part of the human interface for forms on mobile. Checkbox has a smaller hit area than switches.
- Switch is very popular in UI frameworks that have been providing this as a component to use - Material Design, Bootstrap, React Native
- Switches are non-trivial to implement properly in CSS. See Codepen, W3Schools. Most frameworks that are provided to generate HTML on the server do not have a switch causing developers, especially enterprise using checkbox in the place of a switch. PWAs without switches appear non-native on mobile platforms.
- Implementing switches should have no performance overhead for the browsers (separate component in the UI).
I am happy to help writing a spec for the <input type="switch" /> element if that can help getting it into the browsers.
Reacted by Marek Hrabe, Yoshiaki ITO, Kagami Sascha Rosylight, Kravimir, Glen, cybai, Frederik Bosch, Lele E., Jan, Karthick C and 48 more
Reacted by Derek Gray, Mark, Raura, jimmyfrasche, Seirdy, Luciano Lima, M Behzad, Jakob Eriksen and Daniel Herr
Reacted by Kosei Kitahara, Marek Hrabe, Kai, Lele E., Yisi, Oliver Williams, Fatih , Luciano Lima and Christian Oliff
Reacted by Karl Horky, Jon McLaren and Christian Oliff
Reacted by Karl Horky, Michal Čaplygin and romw314
Metadata
Metadata
Assignees
Labels
a11y-trackerGroup bringing to attention of a11y, or tracked by the a11y Group but not needing response.Group bringing to attention of a11y, or tracked by the a11y Group but not needing response.accessibilityAffects accessibilityAffects accessibilityaddition/proposalNew features or enhancementsNew features or enhancementsstage: 1IncubationIncubationtopic: formstopic: rendering

Activity
annevk commentedon Nov 19, 2018
Shouldn't this be a checkbox with a different style? E.g.,
appearance: switch?cc @whatwg/rendering
atishay commentedon Nov 19, 2018
Definitely makes more sense as we get backwards compatibility.
annevk commentedon Nov 19, 2018
Apologies for not welcoming you by the way, I missed this is your first issue. Belatedly, welcome! https://whatwg.org/working-mode#changes and https://whatwg.org/faq#adding-new-features provide some context for the way work is done. I think for this particular request there is enough to go on as this is clearly an established UI widget that makes sense to expose the web in some form. Thanks for raising it.
domenic commentedon Nov 19, 2018
Indeed, welcome. I'm glad @annevk pointed you to the adding new features FAQ, as it helps keep specific solutions (e.g.
<input type="switch">) separate from the problem statement ("displaying a control that looks like a switch").Coincidentally we have been having some discussions internally in Chrome about better built-in UI widgets and form controls. At this point I don't have much to report beyond tentative interest in the general program. But there's a lot to still figure out in the specifics: e.g. theme-ability, whether we can do this in a layered way that does not require more browser magic (like
appearancedoes), etc.sideshowbarker commentedon Nov 20, 2018
👍 It also seems worth mentioning that ARIA (since ~1.1 I think) now has a
switchrole:https://w3c.github.io/aria/#switch
atishay commentedon Nov 20, 2018
I am happy to work with the team if any help in needed in getting this spec'ed or implemented, in whatever form it makes sense to get a toggle switch control into the browsers. I will be careful about not having a solution but only a problem in the future.
Really glad to see how active the HTML WG is on their github channel.
annevk commentedon Nov 20, 2018
@sideshowbarker that's very interesting, that almost suggests there is some semantic related to the presentation of a switch checkbox. Using a CSS property at that point wouldn't work well as that couldn't map to ARIA cleanly.
cc @whatwg/a11y
LJWatson commentedon Nov 20, 2018
The ARIA 'switch' role maps to the accessibility APIs, so an element with 'role="switch"' has semantic meaning to screen readers.
malchata commentedon Nov 20, 2018
I don't think this is a bad idea, but proposals for new browser features can take a long time between conception and implementation across platforms—assuming universal adoption is ever achieved.
Because of this, the question that immediately springs to mind for me is "what does a reliable non-JavaScript fallback pattern look like for this?", and
appearance: switch;in combination with<input type="checkbox">seems to provide a foundation for a progressively enhanced and accessible switch element.annevk commentedon Nov 20, 2018
I agree that's a good consideration, but note that
<input type=checkbox switch>would provide that too and is probably more apt given the slight semantic implication.malchata commentedon Nov 20, 2018
Good point @annevk. I can't see any reason why that wouldn't work as well!
66 remaining items
eqiu8 commentedon Mar 27, 2024
pepelsbey commentedon Nov 5, 2024
Given that Safari 17.4 shipped
<input type="checkbox" switch>eight months ago, I wonder what’s the status of this feature from WHATWG’s point of view.annevk commentedon Nov 5, 2024
Hey @pepelsbey! There's a PR for this feature over at #9546 but there's disagreement over to what extent it needs to describe rendering-related requirements. WebKit's opinion is that it's sufficient to say as much as way for other form controls (which is to say not much) whereas other engines prefer a higher bar. I looked into that and the higher bar essentially requires solving it for most form controls as they are all rather similar in their opaqueness which makes it a bit of a tall order. And we also haven't gotten engagement on the related CSS WG issues to solving that (despite assurances to the contrary above), putting it all in a bit of limbo state unfortunately.
mfreed7 commentedon Nov 6, 2024
I'm not sure that's required here, since this is a brand-new control. There shouldn't be compat issues.
The last conversation that I'm aware of was the Sept 19 TPAC meeting, at which Apple said there was a forthcoming specific proposal that needed "1 month of legal review" and then would be made public. If we missed the publication of this proposal, awesome - can you please provide a link? I had been assuming it'd get linked on w3c/csswg-drafts#10866. Chromium is very much supportive of solving the general form stylability problem, so it'd be unfortunate if there's been a miscommunication.
annevk commentedon Nov 7, 2024
It's not about compatibility issues though. It's about deciding which properties apply and do not apply for
appearance: auto(and same fornone). That should be the same across controls.@mfreed7 I'm not sure what you mean. @chrishtr post above cites a number of CSS WG issues I brought up that lack replies from Google and Mozilla and we were told we would get replies on. The problem here is not
appearance: base, or at least I thought it was not.chrishtr commentedon Nov 7, 2024
I didn't cite them, I just quoted your comment listing them. I do still agree it would be good to make progress on them.
Just enumerating them and suggesting next steps:
For w3c/csswg-drafts#9830 my suggestion is for you to propose names and Agenda+ the issue, since bikeshedding like that is best done in WG calls. I've Agenda+'d it.
For w3c/csswg-drafts#9825 is quite broad, do we need to do anything for that or is 9830 sufficient?
For w3c/csswg-drafts#9832 I'm not sure and a good next step is to ask the CSSWG for feedback. I've Agenda+'ed it.
For w3c/csswg-drafts#4410, is it relevant to checkbox switch?
annevk commentedon Nov 8, 2024
Oh right, I'll blame that on not being a native speaker.
You missed w3c/csswg-drafts#10039 which I think is the most relevant as the other issues are more about
baseappearance and pseudo-elements, which we should do, but I don't think were the actual blocker?The range-related issues can probably be ignored for now in favor of 9830, although I suppose it really depends on how we end up deciding on the pseudo-elements and what they need to be consistently named with.
chrishtr commentedon Nov 8, 2024
Ok. It looks like you asked two questions when filing that issue, which Mason answered in order to unblock your proposed path to specifying them from my perspective.
Cherry-pick ac733e6. rdar://121053711
annevk commentedon Aug 20, 2026
@leotlee @jstenback I'm not entirely sure why we are using the stages process for this. We have a PR that modulo rebasing is ready to land, provided there is implementer interest.
Add the switch attribute to the input element