Use a Switch when you want a user to easily toggle between two mutually exclusive options, like 'on' and 'off' typically for settings or preferences within an application.
The default checkedness of the element. This value sets the `checked` property
only when the `checked` property has not been explicitly set.
disabled
boolean
Sets the element's disabled state. A disabled element will not be included during form submission.
initialValue
string
The default value of the element. This value sets the `value` property
only when the `value` property has not been explicitly set.
label
string
Provides the label for the Switch
name
string
The name of the element. This element's value will be surfaced during form submission under the provided name.
readOnly
boolean
When true, the control will be immutable by user interaction. See https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/readonly | readonly HTML attribute for more information.
required
boolean
Require the field to be completed prior to form submission.
The default checkedness of the element. This value sets the `checked` property
only when the `checked` property has not been explicitly set.
disabled
boolean
Sets the element's disabled state. A disabled element will not be included during form submission.
value
string
The default value of the element. This value sets the `value` property
only when the `value` property has not been explicitly set.
label
string
Provides the label for the Switch
name
string
The name of the element. This element's value will be surfaced during form submission under the provided name.
readonly
boolean
When true, the control will be immutable by user interaction. See https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/readonly | readonly HTML attribute for more information.
required
boolean
Require the field to be completed prior to form submission.
current-value
string
The current value of the element.
Events
Name
Type
Description
change
CustomEvent<undefined>
Emits a custom change event when the checked state changes
Name
Type
Description
change
CustomEvent<undefined>
Emits a custom change event when the checked state changes
Methods
Name
Params
Returns
Description
checkValidity
boolean
Return the current validity of the element.
reportValidity
boolean
Return the current validity of the element.
If false, fires an invalid event at the element.