page Switchcomponent { seo { title = "Switch component" description = "Theme-aware, responsive switch component." } view {
W WRNexusJS
forms component

Switch

Theme-aware, responsive switch component.

@wrnexus/ui 0.3.58 props0 slots0 events

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

PropTypeRequirementDefault
sizestringOptional"default"
colorstringOptional"primary"
labelstringOptional"Switch"
namestringOptional""
valuestringOptional"on"
checkedbooleanOptionalfalse
disabledbooleanOptionalfalse
classstringOptional""

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>
    }
}
} }