component Switch { outputs { input(payload: { value?: string | number | boolean | null; values?: Array; sourceEvent?: Event; [key: string]: string | number | boolean | null | object } | string | number | boolean | null) change(payload: { value?: string | number | boolean | null; values?: Array; sourceEvent?: Event; [key: string]: string | number | boolean | null | object } | string | number | boolean | null) focus(payload: { sourceEvent?: Event; [key: string]: string | number | boolean | null | object }) blur(payload: { sourceEvent?: Event; [key: string]: string | number | boolean | null | object }) } props { size: string = "default" color: string = "primary" id: string = "" name: string = "" label: string = "Switch" hiddenLabel: boolean = false placeholder: string = "" variant: string = "normal" icon: string = "" iconPosition: string = "start" value: string = "on" checked: boolean = false helperText: string = "" cornerHint: string = "" error: string = "" inline: boolean = false readonly: boolean = false disabled: boolean = false required: boolean = false class: string = "" } functions { client function emitField(nameEvent, sourceEvent) { sourceEvent.stopPropagation(); output[nameEvent]({ checked: sourceEvent.currentTarget.checked, value: value, name: name, sourceEvent: sourceEvent }) } client function preventReadonly(sourceEvent) { if (readonly) sourceEvent.preventDefault() } } view {
{#if cornerHint}{label}{cornerHint}{/if}
{#if helperText}{helperText}{/if}{error}
} style { .wire-next--switch input { appearance: none; position: relative; width: 2.5rem; height: 1.4rem; border: 1px solid var(--wire-color-border); border-radius: 999px; background: var(--wire-color-surface-2); transition: background var(--wire-motion-fast) var(--wire-ease-standard); } .wire-next--switch { min-height: 2.65rem; justify-content: flex-start; } .wire-next--switch > span:last-child { line-height: 1.35; } .wire-next--switch input::after { position: absolute; top: 0.15rem; left: 0.15rem; width: 1rem; height: 1rem; border-radius: 999px; background: var(--wire-color-text); content: ""; transition: transform var(--wire-motion-fast) var(--wire-ease-standard); } .wire-next--switch input:checked { border-color: var(--wire-field-color); background: var(--wire-field-color); } .wire-next--switch input:checked::after { background: var(--wire-color-primary-contrast, #fff); transform: translateX(1.1rem); } } }