Elements

Components

Switch

Switch, dressed in the paper-and-ink system: a track that rests in the inset shade of the paper and fills flat with primary ink when on, the thumb sliding on the spring. The parts — Root, Label, Control, Thumb, HiddenInput.

#Basic usage

switch/basic Vue React

#Props

#Control

A styled part — no props of its own; it takes the anatomy's shared styling.

#HiddenInput

A styled part — no props of its own; it takes the anatomy's shared styling.

#Label

A styled part — no props of its own; it takes the anatomy's shared styling.

#Root

PropTypeDefaultDescription
sizeString as PropType<"sm" | "md" | "lg">"md"One rung for the thumb; the track travels with it.
checkedbooleanThe controlled checked state of the switch
defaultCheckedbooleanThe initial checked state of the switch when rendered. Use when you don't need to control the checked state of the switch.
disabledbooleanWhether the switch is disabled.
formstringThe id of the form that the switch belongs to
idstringThe unique identifier of the machine.
idsPartial<{ root: string; hiddenInput: string; control: string; label: string; thumb: string; }>The ids of the elements in the switch. Useful for composition.
invalidbooleanIf true, the switch is marked as invalid.
labelstringSpecifies the localized strings that identifies the accessibility elements and their states
namestringThe name of the input field in a switch (Useful for form submission).
readOnlybooleanWhether the switch is read-only
requiredbooleanIf true, the switch input is marked as required,
valuestring"on"The value of checkbox input. Useful for form submission.

#Thumb

A styled part — no props of its own; it takes the anatomy's shared styling.