KANTO DS v1.12.0
Customise

Theme

Accent

Font

Corners

Density

Text size

Reset to Kanto
Forms

kt-toggle

GitHub Copy link

An on/off switch.

Preview

Notifications Compact rows Unavailable

An on/off switch.

<kt-toggle checked>Notifications</kt-toggle> <kt-toggle size="small" label="Dark mode"></kt-toggle> <kt-toggle disabled></kt-toggle>

Sizing

The switch is derived from the field height rather than given fixed pixels: the track is 1.8× --switch-height, and the thumb is inset by 12% of it. So a toggle lines up with the inputs and buttons next to it, at every size and every breakpoint, and overriding --button-height moves all of them together.

Switch, not checkbox

role="switch" with aria-checked, which screen readers announce as "on"/"off" rather than "checked". Use it for a setting that takes effect immediately. For something that only applies when a form is submitted, a checkbox is the honest control.

In a form, an unchecked toggle contributes nothing to the submission and a checked one contributes its value — the same rule as a native checkbox.

API

PropertyAttributeTypeDefault
checkedcheckedbooleanfalse
disableddisabledbooleanfalse
sizesize'small' | 'medium' | 'large''medium'
namenamestring''
valuevaluestring'on'
labellabelstring''
EventDetail
kt-change{ checked: boolean }
PartDescription
baseThe role="switch" button
trackThe track
thumbThe sliding thumb