-
Notifications
You must be signed in to change notification settings - Fork 8
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
Switches and checkboxes are stylistic variants, not semantically different controls #19
Comments
I guess I should add why I raise this concern. The web ought to be platform-independent to the extent as possible. Therefore introduction of concepts related to native platforms should involve a survey of all reasonably popular ones, not just the top 1 or 2 by installed base. |
An input type=checkbox represents something that can be on or off. Similar to a switch. So they are semantically equivalent. Could we agree on this first ? In the readme is written that the intent is different: Switch are used for more instant interactions: I think this is highly subjective. Even if research shows that it is true, would different intent mean different semantic ? Maybe a switch is just a different visual representation over a checkbox. If that is the case it could potentially be solved by CSS. For the goals in the readme
easyCreate an appearance macro
There is another open discussion about potentially exposing styling for title tooltips. Overall I suggest to make this proposal as small , atomic as possible. Adding the ability the fully customize the appearance seems out of scope, I mean it can be done in a follow up proposal. |
Not sure why confused emoji. Is there a specific question, or should I just try to explain the points more concisely? |
For an example of a robust toggle switch implemented in just CSS, see Under-Engineered Toggles. At more than 250 lines of CSS, it is by no means trivial, but certainly doable, and easily packagable into a library. Notably,
Is that enough reason to make a whole new |
Checkbox and switch are not semantically equivalent. They have different possible values:
They have different semantics regarding the point in time at which the user commits to the changed value (e.g. it gets saved somehow).
|
I think @othermaciej raises a fair point that on iOS and macOS they have historically been treated as stylistic variants. From what I understand that is changing; the recent WWWDC featured the introduction of However, I think we have a pretty clear precedent on the web for switches being distinct. This comes in part from the accessibility tradition, as embodied by the ARIA specs and as discussed by @scottaohara in #15 (comment), as well as from the general patterns of web design systems, and web apps. So I agree that (modulo recent macOS changes of which I don't know the details) people using web technologies to build macOS or iOS apps should follow the HIGs there. But my opinion is that on the web itself, there's an established important distinction in accessibility, functionality, and intent, beyond just the stylistic differences. |
Some evidence has been presented that switch vs checkbox is a commonly accepted distinction either in general or on the web. I think much of that evidence suffers from platform bias, being based on either Windows or Material design or similar resources; in any case, none of it, even advice not specifically targeted at web design, seems to even mention the fact that macOS and iOS are different. To address some specific examples:
Not really the case. Normal checkboxes will only cycle between the checked and unchecked states and will never expose mixes. A few rare checkboxes (both in native platforms and on the web) show the mixed/indeterminate state. But, while HTML has the ability to render the mixed state, it cannot expose a true tristate without additional script for state cycling. A tristate checkbox control arguably is more semantically different from a regular checkbox than a switch is. Finally, the claim that checkboxes are naturally tristate is contrary to what the HTML Living Standard says: "The input element represents a two-state control that represents the element's checkedness state."
The Wikipedia article cites no references regarding macOS and seems to be written in total ignorance of it. macOS has had checkboxes with immediate effect since before most of the platforms used as examples existed.
Once the macOS Catalina public beta comes out, it will be possible for anyone to confirm whether any system UI has changed to stop using checkboxes that have immediate effect and has replaced them with switches. Anyone with access to the developer beta can check now. It should also bee added that Cocoa has long offered stylistic variants of controls that are semantically equivalent, including toggle buttons that are like checkboxes or the new switches but which look different, and multiple variants of buttons.
I tried to do a cursory check of websites where checkboxes are present. It does seem that most checkboxes require a further step to have effect. Some of the most notable exceptions I could find are checkboxes in the ribbon on office.com documents and checkboxes found anywhere on iCloud.com,. Switches seem to be rarely found except on Google web properties using material design (the only place I could find was accounts.google.com but I'd guess with more effort others could be found). A much more common patter for instant-apply boolean states are toggle buttons, which change to a depressed state or otherwise change contents or appearance, but which contain their label (like the Subscribe button on YouTube, or the ubiquitous B/I/U rich text editing buttons). Overall, it doesn't seem to be the case that the switch is the predominant instant-apply boolean control in practice on the web. Finally, it should be noted that the HTML Living Standard does not specify that the semantics of Overall, it's not clear to me that this is representing a real de facto pattern in web design rather than platform bias plus third-party guides written with platform bias. |
In the accessibility layer at least the semantics of switch are a distinct variant of the checkbox, in that the switch role represents a checkbox that has specific states on/off as compared to checkbox which has the more generic checked/unchecked. The 2 (checkbox/switch) are exposed in acc APIs: switch role mappings and checkbox role mappings. Perhaps @cookiecrook could provide some input as he proposed the addition of a distinct switch role in ARIA. |
Switches usually apply to a single boolean mode or option (on/off) that is independent from any others. However, you will find instances of each of these that is used for the standard purpose of one of the other, since their semantics are in fact so similar. Therefore, I believe the differences only justify as much distinction as between |
And they often stand alone too. For example, many login forms have a single "keep me logged in" checkbox.
And they are often found in groups, too. This is especially apparent in iOS Settings (one of the first places to commonly use this control style) where you often see lists of related switches. Google account settings also have groups and switches.
I think the big challenge with this approach is that new input types fall back to |
I'd argue that a standalone Checkbox can always be replaced by a Switch (or perhaps Toggle) without affecting semantics. Instead of dedicated new Groups and Mandates
Numeric Values
Size
|
We took this critique to heart and went to confirm that our intuition about the importance of switch was not limited to Material Design properties. Here are some examples we found on sites we use daily, plus some comments as to whether they appear to be stylistic or semantic decisions. Microsoft Office 365 OutlookUses switches for things that instantly change, and checkboxes for things that need to be "Save"ed: Facebook Messenger.comUnclear what criteria they are using between switches and checkboxes. Both seem to apply instantly, and pressing Esc does not undo the choice. This may indeed be stylistic. Facebook.comUses switches for settings which apply instantly, and checkboxes for things which you need to take further action to process. app.starbucks.comUses switches for settings which apply instantly. Uses a checkbox for "remember me" on their sign-in screen. cointracking.infoUses switches for settings which apply instantly to the current data visualization. yahoo.co.jpFound a switch! @tkent-google can expand if needed. kuronekoyamato.co.jpFound a bunch of switches! @tkent-google can expand if needed. |
this is a switch to enable personalized ads (the label translates as "enable tracking data for advertising and etc." or something like that). this one is a bit awkward... the "switches" on the second column is to choose pickup between home and local business office. comparing to other ones these are just ill-designed radio buttons... |
I don't oppose the opinion that switches are stylistic variants of checkboxes. However, switch should be implemented as a separated type because its UI is different from checkbox. A switch widget typically have some UI parts such as a track and a thumb. We'd like to provide ability to customize each of them, and probably these parts will be exposed as pseudo elements or shadow parts. A checkbox doesn't have such parts. If switches and checkboxes were implemented as a single type., and UA would need to reconstruct shadow trees depending on switch-or-checkbox, and a DOM-level flag would be necessary to distinguish them, not a CSS property. |
The explainer argues that a switch is a semantically different control from a checkbox, citing style guides that suggest different usage. The style guides roughly suggest that switches should be used for actions with immediate effect, while checkboxes are used where an extra step like a Submit button is required.
At least on macOS and iOS (the operating systems that most brought these respective controls to respective prominence), this is not true.
macOS does not have a standard switch control and it is not seen in the default system UI or built-in apps (at least as far as I've seen; there may be exceptions). Checkboxes are often used for actions with immediate effect. In fact, this is the most common use. Preference dialogs on macOS are modeless and their controls are expected to have instant effect, without requiring an extra apply step. These dialogs often contain checkboxes.
iOS, on the other hand, does not have checkboxes as a standard control. (Exception: WebKit renders
<input type=checkbox>
as a checkbox on iOS largely for web compatibility reasons and legacy, e.g. switches are generally labeled on the opposite side from checkboxes but a checkbox element does not contain its label.) Switches are used for the same purpose as checkboxes on macOS. In fact, directly corresponding settings have a checkbox on iOS but a switch on macOS.At least for these two platforms, checkbox and switch are stylistic variants of the same basic semantic. The idea that both always exist and mean different things is biased towards specific and fairly new platforms.
References: the macOS Human Interface Guidelines and iOS Human Interface Guidelines (not cited in the explainer, but probably should be). Note that the macOS version does not describe switches, and the iOS version does not describe checkboxes, because each has only one of these.
Because of this, I think the decision to make this a new element may be based on a faulty premise.
The text was updated successfully, but these errors were encountered: