Switch - Web Component โ
The Switch component can be used imported from:
Playground โ
Parameters โ
The Web component uses the <z-switch>
tag:
By default, all the parameters are optional or can be set in different, except for the ones marked as required
The parametrization of the component can be done with the following custom HTML params:
Name | Type | Description | Slot | A11y |
---|---|---|---|---|
label | string | Label of the input | label | |
model | boolean | Value of the model | ||
checked | boolean | Overrides the "value" parameter as in the standard | ||
invalid-text | string | The text to be shown when invalid | invalid-text | |
disabled | boolean | Blocks the interaction with the input component. | ||
required | boolean | Marks the input component as required. | ||
name | string | Identification for the field inside the form |
Events โ
This component has events. Check the documentation about how to use the events.
Name | Payload | Description |
---|---|---|
change | boolean | Returns the new value of the "value" attribute |
restarted | void | Emitted on value reset |
Slots โ
This component has slots. Check the documentation about how to use the slots.
Name | Tags | Description |
---|---|---|
default | span | |
invalid-text | span |
Parameters use โ
label
โ
The z-switch
component accepts a label
attribute to set the text label of the component.
The slot label
can also be used:
model
โ
Both value
and checked
parameters are used to set the value of the component.
name
โ
The name
attribute is used to set the name of the component. This is useful when the component is inside a form.
invalid-text
โ
The invalid-text
attribute will set the component as invalid. Without label, the text won't be present but the switch will still be invalid,
We can also use the invalid-text
slot:
Flags โ
disabled
โ
The attribute disabled
will block the interaction with the component.
And with labels:
required
โ
The attribute required
will set the component as required.
Browser support โ
Detected engine: ย
Chromium
Webkit
Gecko