aardrian,
@aardrian@toot.cafe avatar

Remember, this is not in the WHATWG HTML spec:

<input type="checkbox" switch>  

https://github.com/whatwg/html/pull/9546

Safari simply decided to implement it, perhaps to force adoption and make another flippant claim it was first with something (when it gets merged into the versionless spec).
https://adrianroselli.com/2021/10/switch-role-support.html#Update02

moopet,
@moopet@toot.cafe avatar

@aardrian what does "allow for a two-state switch control" even mean?

How many states do they think a checkbox has?

aardrian,
@aardrian@toot.cafe avatar

@moopet A checkbox has three states (checked, not checked, mixed) and that is apparently one too many for this person (and an ARIA switch role).

moopet,
@moopet@toot.cafe avatar

@aardrian by "mixed" do you mean the purely visual "indeterminate" state?

aardrian,
@aardrian@toot.cafe avatar

@moopet That is not purely visual. It's a programmatic state you can set and query.

sarajw,
@sarajw@front-end.social avatar

@aardrian if only there was proper advice on how to use these switches, rather than simply in place of a checkbox, which is wrong, imo.

It would be better if these switches were always in the middle, between two options, both labelled either side of it. Blob on left, option 1, blob on right, option 2. That's an entirely new input, not a pseudo-checkbox.

yatil,
@yatil@yatil.social avatar

@sarajw @aardrian No, switches between two values can be super confusing and take up a lot of space. Plus you cannot assign two accessible names to one control in a meaningful way.

They are just switching something off or on, like a checkbox. It’s just another visual for a checkbox, not more, not less. Especially how iOS and also the Webkit implementation uses it: Light off/0 state = off, Light on/1 state = on.

sarajw,
@sarajw@front-end.social avatar

@yatil @aardrian ok. But they're super ambiguous as an off/on!

Or, rather the way they often appear online, with various styles, seems ambiguous

yatil,
@yatil@yatil.social avatar

@sarajw @aardrian Agreed!

Especially on the web they are often used for things that are not off/on, but that’s more a case of “web developers use a thing used for use case A and then apply it to use case B”. If you look at the use of switches in native iOS/macOS, it’s very consistent. That’s also why I think other platforms shouldn’t even bother implementing it. The support is mostly for web embeds in native apps in my opinion.

sarajw,
@sarajw@front-end.social avatar

@yatil @aardrian then that would make more sense for only safari to have implemented it.

yatil,
@yatil@yatil.social avatar

@sarajw @aardrian Yeah, I have one client that has a mix of native views and web views in the app, and when using accessibility features (more contrast, distinguish without color, …) the native switches adapted, the facsimiles in web view didn’t. So for that use case, it makes a lot of sense.

I think in other situations, checkboxes are generally a better choice.

tennoseremel,
@tennoseremel@lor.sh avatar

@aardrian Even if it will exist in a future standard I'd prefer if it said DO NOT USE right there in the description, TBH. Its state is too ambiguous %)

aardrian,
@aardrian@toot.cafe avatar

@tennoseremel But how else could Apple argue it cannot be removed owing to use in the wild and backward compat?

alvaromontoro,
@alvaromontoro@front-end.social avatar

@aardrian It's a nice addition, but the implementation seems a bit rushed. The control doesn't scale properly and visually breaks when changing the zoom level.

aardrian,
@aardrian@toot.cafe avatar

@alvaromontoro If you leave that as a comment I won’t have to remember tomorrow. Can link to the pic you just shared.

jscholes,
@jscholes@dragonscave.space avatar

@aardrian I'm sure they had many reasons for proposing an attribute instead of a new input type, ranging from good(?), through esoteric, all the way to "this is bad but who cares". It seems weird to me, though; the fact that something is a switch is not an aspect of state. I am probably missing some context decided in 1993 that would make it seem reasonable.

aardrian,
@aardrian@toot.cafe avatar

@jscholes Safari already had code for ARIA switches, so glomming on to the first HTML proposal they like (assuming this was not filed by an Apple proxy) seems legit if it means another claim of “First!”

But yeah, could also be some leftover 1990s argument driving it too.

AmeliaBR,
@AmeliaBR@front-end.social avatar

@aardrian @jscholes I believe the argument for using a separate attribute was to create good fallback to a regular checkbox, which I think is an important consideration.

I do think the boolean attribute is kind of a random inconsistent pattern, but on the other hand: there's nothing really consistent about how existing <input> elements work in HTML!

If it weren't for ARIA treating switches & checkboxes differently, I would have preferred to do this all with the CSS appearance property.

aardrian,
@aardrian@toot.cafe avatar

@AmeliaBR @jscholes The entire argument for that implements is in the issue I linked. We were talking (or I was) why Apple chose to treat this PR as if it was done.

I also agree the ARIA switch not allowing a mixed state is not only a confusing lack of parity but probably a lack of imagination on the part of the authors.

I may also be rambling from too many mumma and coffee breaks.

  • All
  • Subscribed
  • Moderated
  • Favorites
  • random
  • kavyap
  • ngwrru68w68
  • cisconetworking
  • osvaldo12
  • everett
  • DreamBathrooms
  • thenastyranch
  • magazineikmin
  • khanakhh
  • Youngstown
  • InstantRegret
  • slotface
  • rosin
  • tacticalgear
  • megavids
  • GTA5RPClips
  • anitta
  • Leos
  • mdbf
  • Durango
  • ethstaker
  • modclub
  • cubers
  • provamag3
  • tester
  • normalnudes
  • JUstTest
  • lostlight
  • All magazines