[whatwg] Add <input> "Switch" Type

Brian Blakely anewpage.media at gmail.com
Wed Dec 18 10:46:49 PST 2013


On Tue, Nov 19, 2013 at 6:29 AM, Elliott Sprehn <esprehn at chromium.org>wrote:

> On Tue, Nov 19, 2013 at 1:37 AM, Jonas Sicking <jonas at sicking.cc> wrote:
>
> > Realistically speaking, I don't think this will help much at all. Few
> > websites like using the default styling for form controls anyway and
> > so people would be just as unhappy with the default switch rendering
> > as they are with the default checkbox rendering.
> >
> > The real fix is to allow styling formcontrols. It's one of the most
> > requested features from web developers, yet no one has taken the time
> > to research what it would take to do it.
> >
> > I'm quite sure that if someone comes up with a comprehensive and well
> > researched proposal, that browsers would jump on it.
> >
> > And the fact that we now have shadow DOM defined should help a whole lot.
> >
> >
> +1, a switch is just a styled checkbox. We don't need more input types or
> attributes, we just need to standardize how to style type=checkbox.
>
> - E
>

A switch is definitely NOT simply a styled checkbox.  As I mentioned
earlier, you can slide/drag a switch to change its value.  Also, a switch
typically animates, whereas a checkbox is essentially a more static
interaction.  A switch is often used to indicator more than true/false
(which should ultimately be represented).

Regardless of what one's opinion might be on the similarity to checkboxes,
input types in HTML are not subject to the same semantics as other kinds of
elements.  Half of them are purely presentational or pave cowpaths.

Switches on the Web are currently janky, inconsistent and difficult to
implement.  That is essentially the exact same reason that type="week" or
type="color" have value.  Before formal implementations, they had been
implemented for a very long time with type="text" and mountains of dubious
code.

Considering that every major UI toolkit now includes switches discretely
from checkboxes, it makes a great deal of sense to include them in the Web
Platform.  It does not make sense to exclude switches simply because we can
abuse checkboxes to create something weakly approximate to a switch.


More information about the whatwg mailing list