:host { --background-color: var(--wa-form-control-background-color); --background-color-checked: var(--wa-form-control-activated-color); --border-color: var(--wa-form-control-resting-color); --border-color-checked: var(--background-color-checked); --border-style: var(--wa-form-control-border-style); --border-width: var(--wa-form-control-border-width); --box-shadow: initial; --height: calc(1em * var(--wa-form-control-value-line-height)); --thumb-color: var(--wa-form-control-resting-color); --thumb-color-checked: var(--wa-form-control-background-color); --thumb-shadow: initial; --thumb-size: calc((var(--height) - var(--border-width) * 2) * 0.75); --width: calc(var(--height) * 1.75); display: inline-block; } .switch { position: relative; display: flex; align-items: center; font: inherit; color: var(--wa-form-control-value-color); vertical-align: middle; cursor: pointer; } .control { flex: 0 0 auto; position: relative; display: flex; align-items: center; justify-content: center; width: var(--width); height: var(--height); background-color: var(--background-color); border-color: var(--border-color); border-radius: var(--height); border-style: var(--border-style); border-width: var(--border-width); box-shadow: var(--box-shadow); transition: background var(--wa-transition-normal) var(--wa-transition-easing), border-color var(--wa-transition-normal) var(--wa-transition-easing); } .control .thumb { width: var(--thumb-size); height: var(--thumb-size); background-color: var(--thumb-color); border-radius: 50%; box-shadow: var(--thumb-shadow); translate: calc((var(--width) - var(--height)) / -2); transition: translate var(--wa-transition-normal) var(--wa-transition-easing), background-color var(--wa-transition-normal) var(--wa-transition-easing), border-color var(--wa-transition-normal) var(--wa-transition-easing), box-shadow var(--wa-transition-normal) var(--wa-transition-easing); } .input { position: absolute; opacity: 0; padding: 0; margin: 0; pointer-events: none; } /* Focus */ .switch:not(.switch--disabled) .input:focus-visible ~ .control .thumb { outline: var(--wa-focus-ring); outline-offset: var(--wa-focus-ring-offset); } /* Checked */ .switch--checked .control { background-color: var(--background-color-checked); border-color: var(--border-color-checked); } .switch--checked .control .thumb { background-color: var(--thumb-color-checked); translate: calc((var(--width) - var(--height)) / 2); } /* Disabled */ .switch--disabled { opacity: 0.5; cursor: not-allowed; } .label { display: inline-block; line-height: var(--height); margin-inline-start: 0.5em; user-select: none; -webkit-user-select: none; } :host([required]) .label::after { content: var(--wa-form-control-required-content); color: var(--wa-form-control-required-content-color); margin-inline-start: var(--wa-form-control-required-content-offset); } @media (forced-colors: active) { .switch.switch--checked:not(.switch--disabled) .control:hover .thumb, .switch--checked .control .thumb { background-color: ButtonText; } }