Skip to content
Nana UI

Switch

A form-associated on/off switch. Works inside a native <form>, supports keyboard toggling, and mirrors native checkbox semantics for submission.

Enable notifications
Terminal window
npm install @nana-tec/ui-components
import "@nana-tec/ui-components/switch";
<nana-switch>Enable notifications</nana-switch>
Small Medium Large
On Off Disabled on Disabled off
PropertyTypeDefaultDescription
checkedbooleanfalseOn/off state.
disabledbooleanfalseDisable the control.
requiredbooleanfalseMark as required for form validation.
valuestring'on'Submitted value when checked (default “on”).
namestring''Form field name.
labelstring | undefinedConvenience label text (slotted content wins).
descriptionstring | undefinedSecondary descriptive text.
size'sm' | 'md' | 'lg''md'Control size.
EventTypeDescription
nana-changeCustomEventFired on toggle (detail.checked).
SlotDescription
(default)The label (overrides the label attribute).
descriptionSecondary descriptive text.
VariableDefaultDescription
--nana-switch-accentChecked track colour.
--nana-switch-thumbThumb colour.
PartDescription
baseThe clickable row
controlThe track
thumbThe sliding thumb
labelThe label text
  • Keyboard accessible
  • Screen-reader labels
  • Focus-visible states
  • ARIA roles and states
  • WCAG 2.2 AA contrast
Explore Switch interactively Every state, prop, and edge case — with live controls — in Storybook.
View in Storybook