ArtificialSenseDocs

Docs / Components

SenseToggleSwitchComponent

Accessible on/off switch from @artificialsenselabs/ui with label, keyboard support, and forms integration.

Live demo: run nx serve showcase and open /components/toggle-switch (port 4202).

Overview

Category: Form control. Selector: sense-toggle-switch. Import: import { SenseToggleSwitchComponent } from '@artificialsenselabs/ui';

<sense-toggle-switch
  label="Notifications"
  [(checked)]="enabled"
/>

Bind [(checked)] without forms, or [(ngModel)] / formControl with them. checkedChange is the change event; switchChange is deprecated and is removed in 1.0 (ADR-0056).

Inputs & outputs

MemberTypeDefaultDescription
labelstring | nullnullVisible label; omit when using ariaLabel alone.
ariaLabelstring | nullnullAccessible name when no visible label.
checkedbooleanfalseTwo-way model for on/off state.
size'sm' | 'md' | 'lg''md'Visual density preset.
readonlybooleanfalsePrevents toggling while keeping the control focusable.
switchChangeSenseToggleSwitchChangeEvent—Emits { checked, originalEvent } on user toggle.

Accessibility

  • Native checkbox with role="switch" per the ARIA switch pattern.
  • Visible labels use aria-labelledby; icon-only uses aria-label.
  • Space key toggles when focused; decorative track is aria-hidden.
  • Implements ControlValueAccessor for Angular forms integration.