Skip to content
kitn AI/UI

Switch

kai-switch

A toggle switch for a setting that applies the moment it flips — “Temporary chat”, notifications, a feature flag. It manages its own on/off state and reports changes with a single event.

  • Shadow DOM
  • 1 event
  • role="switch"
  • Keyboard operable
  • Self-managing

Set the initial state with the checked attribute and read changes from kai-change:

<kai-switch checked label="Temporary chat"></kai-switch>
<script type="module">
import '@kitn.ai/ui/elements';
document.querySelector('kai-switch')
.addEventListener('kai-change', (e) => console.log('checked:', e.detail.checked));
</script>
  • Self-managing — the switch toggles on click or Space/Enter and tracks its own state; you only listen for kai-change.
  • checked — a bare attribute (<kai-switch checked>) starts it on.
  • label — sets the accessible name (aria-label); the switch is visual-only, so always provide one.
  • disabled — blocks interaction and dims the control.

Starts on via the checked attribute.

Non-interactive and dimmed.

PropertyTypeDefaultNotes
checked Initial checked state. Bare attribute (`<kai-switch checked>`) turns it on.
disabled Disable interaction.
label Accessible label.
EventDetailNotes
The toggle changed.

This element wraps these SolidJS components — reach for them directly when you need finer control than the props expose.

Switch