Switch

stable 2.1 kB
<hk-switch>

A checkbox that reads as an on/off control. Model-bound through a signal, so [(checked)] is all the wiring it needs — no ControlValueAccessor boilerplate.

#toggle#checkbox#boolean
In the package npm i hellskitchen-ui Import hk-switch and use it directly.

Live demo

Running in this page — interact with it.

Inputs

NameTypeDefaultDescription
checkedbooleanfalseModel value. Supports two-way binding via [(checked)].
size'sm' | 'md' | 'lg''md'Track and thumb scale.
accentstring'crimson'Named accent, or any CSS colour.
labelstring''Accessible label, applied as the switch’s aria-label.
disabledbooleanfalseBlocks interaction and dims the track.

Outputs

  • changedEventEmitter<boolean>

    Fires with the new value after a toggle.

Keyboard

  • Space / Enter Toggles the value
  • Tab Moves focus in and out

Theming

Component tokens, each falling back to a global one:

PropertyDefaultControls
--hk-switch-track#262626Track colour when off.
--hk-switch-thumb#ffffffThumb colour.
--hk-switch-easecubic-bezier(.34,1.56,.64,1)Thumb travel easing.

Accessibility

  • Renders role="switch" with aria-checked reflecting the model.
  • Label is wired through aria-label or aria-labelledby, never left implicit.
  • Thumb travel honours prefers-reduced-motion.

More in Forms