thumb.
MultiSwitch has three: thumb (one render in the moving thumb), segment (one render per step background), and label (per-step label). All snippet contexts use { index, item, isSelected } (thumb on MultiSwitch omits isSelected — it's always true).AD01 Switch — thumb snippet
Custom content inside the moving thumb
Live Demo
Code
Notes
The thumb snippet
The thumb snippet replaces the default thumb content. For a
binary Switch, the snippet runs once and you usually read the checked state from your own scope (as both examples here do).
Snippet context
If you supply items, the snippet receives { index, item } describing the active half of the tuple.
For pure binary toggles you can ignore the context entirely.
AD02 MultiSwitch — segment snippet
Custom content rendered once per step background. Pair with thumb to also fill the moving thumb.
Live Demo
Code
When to use segment
v2.0 split
In 1.x children ran in BOTH the moving thumb and each step
background. 2.0 split that into thumb (one render) and segment (one render per step) so each snippet has one job.
1.x parity pattern
To get the v1.x behaviour where the thumb showed the active item's content,
pass both thumb and segment with
the same markup. Optionally hide the active segment
(opacity: isSelected ? 0 : ...) to avoid double-rendering
underneath the thumb.
segment context
index— Index of the step (wascurrentIndex)item— The item data for this stepisSelected—index === activeIndex
AD03 MultiSwitch — label snippet
Rich per-step labels with full HTML/Svelte content
Live Demo
Code
Notes
label snippet (v2.0)
Renamed from 1.x labelTemplate. Same role: full control over
each per-step label.
Snippet context
index— Index of this labelitem— Item data (typed asT | undefined)isSelected— Whether this label corresponds to the active step
Easier alternatives
If you only need label text, prefer labelMember or labelCallback — see Labels.
AD04 Combined example — thumb + segment + label + itemStyles
Theme selector using all four customization points at once
Live Demo
Code
Combined Use
All four together
itemStyles drives per-step background colours, segment renders the static icon per step, thumb shows the theme name in the moving thumb, label renders the rich per-step caption.
Real-world fit
- Theme selectors
- Media players
- Dashboard controls
- Configuration panels
Snippets with Disabled State
Performance & Best Practices
⚡ Performance Tips
- ✅ Keep snippet logic simple
- ✅ Avoid heavy computations in snippets
- ✅ Use
$derivedfor computed values - ✅ Minimize DOM elements in snippets
- ✅ Cache expensive operations outside the snippet
🎯 Snippet Guidelines
- ✅ Pick the right snippet (thumb vs segment vs label)
- ✅ Design for touch interfaces
- ✅ Ensure content fits in available space
- ✅ Use
?.on optional item properties - ✅ Test with different item shapes