Skip to content

Switch ​

The bq-switch component is a toggle switch form control.

Basic Usage ​

html
<bq-switch label="Enable notifications"></bq-switch>

Checked ​

html
<bq-switch label="Dark mode" checked></bq-switch>

Sizes ​

html
<bq-switch label="Small" size="sm"></bq-switch>
<bq-switch label="Medium" size="md"></bq-switch>
<bq-switch label="Large" size="lg"></bq-switch>

Disabled ​

html
<bq-switch label="Locked" disabled></bq-switch>
<bq-switch label="Locked on" checked disabled></bq-switch>

Properties ​

PropertyTypeDefaultDescription
labelstring—Visible label text
namestring—Form field name
valuestring'on'Value submitted when the switch is on
checkedbooleanfalseWhether the switch is on
disabledbooleanfalseDisables the switch
requiredbooleanfalseMust be on for the form to submit
hintstring—Helper text below the switch
sizestring'md'sm | md | lg

Events ​

EventDetailDescription
bq-change{ checked: boolean }Fired when the toggle state changes

CSS Parts ​

PartDescription
controlThe switch track
inputThe native checkbox input
thumbThe toggle thumb
labelLabel text element

Form Participation ​

The component creates a hidden input proxy for native <form> submission. The proxy submits "on" when checked and is empty when unchecked.

Accessibility ​

  • Uses a native <input type="checkbox" role="switch"> for full keyboard and screen reader support.
  • The toggle state is conveyed via aria-checked.
  • The label is associated with the input via a wrapping <label> element.

Released under the MIT License.