by seanwilson · 3y ago · 0 comments
The general UI rule is use a switch when toggling has an immediate impact (similar to pressing a light switch) vs a checkbox when there's a submission step before it has an impact (similar to ticking a paper form then mailing it). See:
https://www.nngroup.com/articles/toggle-switch-guidelines/.
It made sense after learning this but I didn't find the difference that intuitive before. A lot of UIs get it wrong (e.g. switches in forms, checkboxes for settings that immediately change something) but it only bugs me now I know which one to use. It's not only for cosmetics though.
dark (o ) light (o foo)
(bar o)
And I don't know if I'm supposed to click it to change to `foo`, or if that means it is already in the `foo` mode.This is absolutely a dark pattern.
Is this the same thing that separates those that like to mash all the buttons and twist all the knobs to see what happens vs those that don't want to touch anything because they don't know what will happen?
There's a small problem with your example: Dark mode isn't a binary setting.
For modern applications, there should be 3 settings: System, Light, and Dark. (I like to use a dropdown menu to select the theme).
This makes it work for people whose theme changes automatically between day and night (it's a built-in system setting on macOS, and possibly Windows). L
For a web app, Light and Dark can set a value in localStorage which sets the theme manually, but System should remove the setting.
You can detect the correct theme when the page is loaded, and also add an event listener to detect theme changes (so that either the user or the OS can change the current theme). It's actually not too difficult to set up properly.
The core function of a toggle is to - well - toggle.
Off (o ) On
And the way it was used was Dark (o )
or
Dark ( o)Checkboxes are easy to understand.
If there is immediate effect then using a checkbox also works perfectly fine.
The switch is just always worse (IMO).
I once visited a site that had a hamburger menu holding the navbar that auto-hid if you clicked away. They also had a switch on the corner of the opposite side of the screen that opened the navbar and kept it open
I still sometimes wonder what was going through the UI guy's head when they made that
For the "off" state though, I've never found an empty square outline being that clear (this looks similar to a button or a text field) or easy to spot, and a cross/X in the square instead can also be confused with "on". Not saying a switch fixes this however.
> When turning airplane mode on for iOS, Apple provides immediate results by changing the cellular bars in the upper left-hand corner to an airplane icon.
To summarize, it sounds like the toggles you've experienced haven't led to an immediate state change, which likely identifies them as better candidates for a checkbox like you mentioned.
That separation between immediate and delayed effect seems quite artificial to me, and doesn't exist at all on other types of inputs. It looks like a bad, post-fact justification created just to placate some masses instead of for good fundamental reasons. (And yeah, I do know who I'm criticizing here.)
Anyway, it's a lost battle, so whatever, let's leave with the bad consequences.
In terms of primitive types and common UI platforms, we have this immediate/deferred distinction for booleans and enums.
Booleans are represented by checkboxes vs. switches as already discussed. And enums are represented by radio buttons (the traditional form element) vs. multi-part buttons (which Apple calls segmented controls).
But like designers shouldn't overdesign, we shouldn't overthink what's "correct" use. If it works and/or feels natural, it's ok. If it doesn't, it's time to consider alternatives, but you shouldn't implement them because some rule says so.
I use a switch to toggle one specific thing, checkboxes to pick zero, one, or many related things.
Eg: switch: “slow mode is active for robots in this zone.” Checkboxes: “this applies to robot types A, C, D.”
The only exceptions are cases where partially applied settings can cause problems (like network settings) and the odd holdover that’s survived since the pre-OS-X days (like the settings dialog in Music, previously known as iTunes, previously known as SoundJam MP).