Switch
Form & Input
stable
Toggle switch input that wraps a hidden checkbox for binary on/off state, with optional inset style, loading states and track slot customization.
API
Props
All props accepted by this component, with their type, default value and description.
- indeterminatebooleanfalse
- Puts the switch into a three-state (mixed) visual state. The indeterminate state clears on the next toggle.
- insetbooleanfalse
- Material inset variant — the thumb overflows the track edges and expands when active.
- idstring
- flatbooleanfalse
- Removes the default thumb elevation, producing a flat appearance.
- classstring | Array<string> | object
- stylestring | Array<string> | object | StyleValue
- tagstring'div'
- HTML element rendered at the root.
- paddingboolean | number | string
- paddingTopboolean | number | string
- paddingLeftboolean | number | string
- paddingBottomboolean | number | string
- paddingRightboolean | number | string
- paddingBlockboolean | number | string
- paddingInlineboolean | number | string
- paddingInlineStartboolean | number | string
- paddingInlineEndboolean | number | string
- paddingBlockStartboolean | number | string
- paddingBlockEndboolean | number | string
- marginboolean | number | string
- marginTopboolean | number | string
- marginLeftboolean | number | string
- marginBottomboolean | number | string
- marginRightboolean | number | string
- marginBlockboolean | number | string
- marginInlineboolean | number | string
- marginInlineStartboolean | number | string
- marginInlineEndboolean | number | string
- marginBlockStartboolean | number | string
- marginBlockEndboolean | number | string
- borderboolean | number | string | TDirectionBoth | Array<TDirectionBoth>
- borderTopboolean | number | string
- borderLeftboolean | number | string
- borderBottomboolean | number | string
- borderRightboolean | number | string
- borderBlockboolean | number | string
- borderInlineboolean | number | string
- borderInlineStartboolean | number | string
- borderInlineEndboolean | number | string
- borderBlockStartboolean | number | string
- borderBlockEndboolean | number | string
- borderColorstring
- borderStylestring
- borderTopColorTColor
- borderRightColorTColor
- borderBottomColorTColor
- borderLeftColorTColor
- borderInlineStartColorTColor
- borderInlineEndColorTColor
- borderBlockStartColorTColor
- borderBlockEndColorTColor
- roundedboolean | number | string | TRounded | null | undefined
- roundedTopRightboolean | number | string
- roundedTopLeftboolean | number | string
- roundedBottomLeftboolean | number | string
- roundedBottomRightboolean | number | string
- roundedStartStartboolean | number | string
- roundedStartEndboolean | number | string
- roundedEndStartboolean | number | string
- roundedEndEndboolean | number | string
- centerAffixboolean
- hideDetailsboolean | stringfalse
- Hides the validation messages area below the control.
- hideSpinButtonsboolean
- hintstring
- persistentHintboolean
- messagesArray<string> | string
- densityTDensity'default'
- Adjusts vertical padding density of the input row.
- colorTColor
- Active-state color applied to the thumb and track via intent tokens.
- bgColorTColor
- elevationTElevation
- heightnumber | string
- maxHeightnumber | string
- maxWidthnumber | string
- minHeightnumber | string
- minWidthnumber | string
- widthnumber | string
- directionTDirection
- disabledbooleanfalse
- Disables the switch — prevents interaction and applies muted styling.
- errorstring | boolean
- errorMessagesArray<string> | string
- maxErrorsnumber | string
- namestring
- readonlybooleanfalse
- Keeps the visual appearance interactive but blocks state changes.
- rulesArray<any>
- modelValueany
- Bound value of the switch. Bind with v-model.
- validateOnTValidateOn
- validationValueany
- focusedboolean
- appendAvatarstring
- appendIconTIcon
- prependAvatarstring
- prependIconTIcon
- prependAriaLabelstring
- appendAriaLabelstring
- sizeTSize | number
- fontSizeTFontSize
- fontWeightTFontWeight
- lineHeightTLineHeight
- labelstring
- Visible text label associated with the switch.
- trueValueany
- falseValueany
- valueany
- requiredboolean
- typestring
- valueComparator(a: any, b: any) => boolean
- falseIconTIcon
- trueIconTIcon
- multipleboolean
- inlineboolean
- hoverboolean | IStateEffectConfig
- hoverClassstring
- rippleboolean | { class: string }
- loadingTControlLoadingValuefalse
- Loading state. 'circular' shows a spinner in the thumb; 'line' overlays the track; 'skeleton' replaces the entire switch.
- loadingTextstring
- activeboolean | IStateEffectConfig
- activeClassstring
API
Slots
Content slots exposed by this component.
- #track.true
- Content rendered on the ON (left) half of the track, e.g. a checkmark icon.
- #default
- Label content rendered beside the track.
- #track.false
- Content rendered on the OFF (right) half of the track, e.g. an X icon.
- #loader
- Custom spinner rendered inside the thumb while loading.
API
Emits
Events emitted by this component.
- @update:modelValueany
- Fired when the switch is toggled. Bind with v-model.
- @update:focusedany
- @update:indeterminateboolean
- Fired when the indeterminate state is cleared on toggle.
- @focusFocusEvent
- Fired when the hidden input receives focus.
- @click:labelMouseEvent
- Fired when the user clicks the associated label element.
- @blurFocusEvent
- Fired when the hidden input loses focus.
Interactive
Playground
Edit props live and see the component update in real time. The generated code snippet updates as you change values.
Rendering the live preview…
Usage
Examples
Ready-to-paste code snippets for your templates.
Basic switch
Inset & color
Custom track content
Ecosystem
Family
Components from the same folder that share conventions and often compose together.