Basic Usage

Simple multi-option switch with labels

Live Demo
Choose option:
Option 1
Selected: Option A
Code
 
Explanation

Two-way Binding

Use bind:selectedIndex to track which option is currently selected.

Items Array

Pass an array of strings or objects to define the available options.

Different Option Counts

MultiSwitch adapts to any number of options

Live Demo
Power Level (5 options):
Option 2
Level: Low
Mood (4 emojis):
Option 3
Mood: 😊
Code
 
Guidelines

Flexible Options

MultiSwitch works with 3 or more options. The component automatically adjusts spacing and positioning.

Content Types

  • Text labels
  • Emoji characters
  • Short abbreviations
  • Custom objects

Size Variations

Control the size for different use cases

Live Demo
Small (40px):
Option 1
Default (50px):
Option 1
Large (70px):
Option 1
Selected size: Small
Code
 
Size Guidelines

Choosing Size

  • Small (30-40px): Compact layouts, sidebars
  • Default (50px): Most common use cases
  • Large (60-80px): Touch interfaces, emphasis

Label Considerations

Larger switches provide more space for labels and better touch targets.

Vertical Orientation

Vertical layout for space-constrained designs

Live Demo
Horizontal (default)
Option 2
Vertical
Option 1
Option 2
Option 3
Option 4
Option 5
Selected: Low
Code
 
When to Use

Vertical Benefits

  • Saves horizontal space
  • Works well in sidebars
  • Good for mobile layouts
  • Creates visual hierarchy

Label Positioning

Consider using "right" or "left" label positions with vertical switches for better readability.

Label Positioning

Control where labels appear relative to the switch

Live Demo
Labels on top:
Option 1
Labels on bottom:
Option 1
No labels:
Code
 
Position Options

Available Positions

  • top - Above the switch
  • bottom - Below the switch (default)
  • left - To the left (vertical only)
  • right - To the right (vertical only)

Design Tips

Choose label position based on your layout constraints and visual hierarchy.

Event Handling

Respond to selection changes

Live Demo
Select option:
Option 1
Current: Option A
Code
 
Event Details

onItemChange Callback

The onItemChange prop accepts a function that receives the newly selected index.

Common Use Cases

  • Form validation
  • Loading related data
  • Updating other UI components
  • Analytics tracking

Working with Custom Objects

Using both children and labelTemplate with complex data

Live Demo
Skill level:
B
B
I
A
E
Beginner
Just starting out
Code
 
Template Usage

Custom Object Support

When using complex objects, provide both children and labelTemplate snippets to display different parts of your data.

Template Roles

  • children: Compact display in switch area (first letter)
  • labelTemplate: Full details in labels (name + description)

Best Practices

Keep switch content minimal and use labels for detailed information to maintain readability and usability.

Next Steps

🎨
Styling

Learn to customize colors and styles

Styling Guide
Advanced

Advanced features and techniques

Advanced Examples
📚
API Reference

Complete documentation

MultiSwitch API