Switch
Theme-aware, responsive switch component.
Usage
Components are auto-discovered. Use the component directly in any .wrn view:
<Switch
size="default"
color="primary"
label="Switch"
name="name"
value="on"
/>Legacy mount name: data-component="Switch".
Props and attributes
| Prop | Type | Requirement | Default |
|---|---|---|---|
size | string | Optional | "default" |
color | string | Optional | "primary" |
label | string | Optional | "Switch" |
name | string | Optional | "" |
value | string | Optional | "on" |
checked | boolean | Optional | false |
disabled | boolean | Optional | false |
class | string | Optional | "" |
Slots
This component does not declare a slot.
Events
This component does not declare a custom event.
Source contract
Installed source: components/Switch.wrn
component Switch {
props {
size = "default"
color = "primary"
label = "Switch"
name = ""
value = "on"
checked = false
disabled = false
class = ""
}
view {
<label class="wire-next wire-next--color-{color} wire-next--size-{size} wire-next--choice wire-next--switch {class}">
<input {...attrs} type="checkbox" name="{name}" value="{value}" checked="{checked}" disabled="{disabled}" />
<span>{label}</span>
</label>
}
}