openui / openui/open-ui

[switch] Differentiate the semantics of a switch vs a checkbox

Open
#996 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

needs-triage
Dominant language
MDX
Stars
4.5k
Forks
226
Avg merge
2d 22h
Merged PRs (30d)
4

Description

The draft switch explainer in #785 says "A switch toggles a binary state on or off." In HTML, a checkbox is defined as

The input element represents a two-state control that represents the element's checkedness state. If the element's checkedness state is true, the control represents a positive selection, and if it is false, a negative selection.

The HTML proposal for switch says

The input element, when the switch attribute is set, represents a two-state control representing the element's checkedness. If the element's checkedness state is true, the control represents a positive selection, and if it is false, a negative selection.

This makes it seem like a switch is just an alternate style for a checkbox, and since we try to put style in CSS and semantics in markup, maybe the switch UI should just be appearance: switch on a checkbox input. (And maybe that appearance wouldn't apply to a checkbox with the indeterminate attribute, to avoid needing to answer the question of how to map that to native switch controls.)

But there probably is some reason beyond styling that people use switches instead of checkboxes. It's not that they have an immediate effect: checkboxes can also have an immediate effect. Whatever the reason is, the explainer here and the eventual spec should explain it so that authors can know which to use.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Review the draft switch explainer in issue #785 alongside the linked HTML checkbox definition, HTML switch proposal, and CSS appearance-switching discussion. Determine and document the semantic reason to choose a switch over a checkbox, including how indeterminate checkboxes should be treated; the explainer and eventual specification should give authors clear guidance.

Written by the indexing model from the issue text.

Assessment

Tech stack
css, html
Domain
documentation
Issue type
Documentation
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.