UI Component Lab 日本語

← All components

Input

Switch

Turns a single setting on or off, with the change taking effect right away.

Demo

Also known as

How to recognize it

A pill-shaped track with a round knob. The knob slides to one end and the track changes color when it is on.

Behavior

  • Clicking anywhere on the switch or its label flips the state.
  • There are only two states, on and off; unlike a checkbox, there is no mixed state.
  • The label names the setting and does not change when the state changes.
  • This demo is a native checkbox with role="switch", styled to look like a switch.

Keyboard

KeyAction
SpaceTurns the switch on or off.

Usage notes

  • Use it only for settings that take effect immediately. If a save or submit step is needed, use a checkbox.
  • Checkbox: A switch takes effect right away; a checkbox is often confirmed later with a submit button.
  • Toggle button: A switch looks like a sliding knob and is used for settings; a toggle button looks like a button and is often used in toolbars.

Sources