Installation
Choose your preferred package manager
npm
pnpm
yarn
Quick Start
Basic usage examples to get you started
Basic Switch
Multi Switch
Notes
Two-way Binding
Use bind:checked for Switch and bind:selectedIndex for MultiSwitch. State updates flow both directions.
State Management
Use Svelte 5's $state rune for reactive variables, or any
reactive store pattern you prefer.
TypeScript
Both components are generic over the item type T, inferred from
the items prop. Snippet contexts get the right item type without
explicit annotations.
Vanilla JavaScript Usage
Mount components outside Svelte apps using mount() + $state
Recipe
Why $state?
Svelte 5 props are reactive. Pass a $state object to mount() and mutate it later — no update() method needed.
The 1.x .update() escape hatch was removed in 2.0; this is the
idiomatic Svelte 5 replacement.
Component Overview
🔄 Switch
Binary on/off toggle.
- ✅ Binary (true/false) state via
bind:checked - ✅ Horizontal and vertical orientations
- ✅ Named sizes (xs/sm/md/lg/xl) or numeric pixels
- ✅ Custom
itemStylesper state - ✅ Disabled state
- ✅
thumbsnippet for custom thumb content - ✅ Generic over item type
T
🎛️ MultiSwitch
Multi-step switch (3+ options).
- ✅ Any number of items via
itemsarray - ✅ Auto label rendering with
shouldDisplayLabels - ✅
labelMember/labelCallback/labelsnippet - ✅ All Switch features
- ✅ Separate
thumb+segmentsnippets - ✅ Per-step
itemStyles - ✅ Clickable per-step labels (vertical mode)
Requirements
Svelte 5
Svelte 5 or later. The library uses runes ($state, $props, $derived) and snippets — there is no Svelte 4
compatibility build.