Skip to main content

Switch

The Switch component provides users the ability to choose between two distinct values. These are very similar to a toggle, or on/off switch, though aesthetically different than a checkbox.

A Switch in its simplest form provides a toggle between 2 values.

info

For more details about Vuetify’s usage of Switch component, click Switch page.
For more prop explanations, click Vuetify Switch API page.

Props

AttributeDescriptionTypeDefault
appendiconAppends an icon to the component, uses the same syntax as vIcon.stringundefined
classAllows custom properties to take. effect.stringundefined
compareValueQLegend is used for comparison values. You can look at the QLegend document.stringundefined
compareTextQLegend is used for comparison values. You can look at the QLegend document.stringundefined
compareTableValueQLegend is used for comparison values. You can look at the QLegend document.stringundefined
darkApplies dark theme.booleanfalse
disabledMakes the component useless.booleanfalse
errorPuts the input in a manual error state.booleanfalse
errorCountDisplays the total number of errors at once.number-stringundefined
errorMessagesPuts the input in an error state and passes through custom error messages. Will be combined with any validations that occur from the rules prop.stringundefined
hideDetailsHides hint and validation errors. When set to auto messages will be rendered only if there’s a message (hint, error message, counter value etc) to display.boolean-stringundefined
hintAllows writing recommendation sentences under component.stringundefined
insetEnlarge the Switch track to encompass the thumb.booleanfalse
labelSets input label.stringundefined
loadingDisplays circular progress bar. Can either be a String which specifies which color is applied to the progress bar or a Boolean which uses the components color prop.boolean-stringundefined
persistentHintForces hint to always be visible.booleanfalse
prependInnerIconPrepends an icon to the component, uses the same syntax as vIcon.stringundefined
readonlyPuts input in readonly state.booleanfalse
rippleApplies the ripple directive.boolean-objecttrue
successPuts the input in a manual success state.booleanfalse
successMessagesputs the input in a success state and passes through custom success messages.stringundefined
tabindexAllows component to give and receive focus.numberundefined
validateOnBlurDelays validation until blur event.booleanfalse
valueComparatorapplies a custom value comparator function.functionnull
valueSets the switch is checked or not.booleanfalse
visibleVisibility of Switch component.booleantrue

image

Events

AttributeDescription
changeEmitted when the input is changed by user interaction
clickEmitted when input is clicked. Note: the change event should be used instead of click when monitoring state change

Samples Qjson

SwitchComponent