LB01 Label Positioning

Control where labels appear relative to the switch

Live Demo
Top Labels:
Option 1
Bottom Labels:
Option 2
Left Labels:
Right Labels:
Code
 
Position Guidelines

Position Options

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

💡 Tip: Block render mode

All examples on this page use labelRenderMode="block", which reserves space for labels in document flow. This is the recommended mode for most layouts.

labelRenderMode="absolute" is the legacy default — labels are absolutely positioned and don't reserve space, requiring manual padding on the container. See the next section for the comparison.

LB02 Label Render Mode

Choose between absolute and block positioning for labels

Live Demo
Absolute Mode (Default)
⚠️ Labels don't reserve space — manual padding needed
Absolute:
Option 2
Without padding-bottom, the next element overlaps the labels.
Block Mode
✅ Labels take up space automatically
Block:
Option 2
Next element flows naturally, no padding needed.
Block Mode — Vertical
✅ Block — works with vertical too
⚠️ Absolute — needs padding
Code
 
Render Mode Comparison

Render Modes

absolute (default)
  • Labels use absolute positioning
  • Don't affect layout flow
  • Require manual padding
  • More control over exact positioning
block
  • Labels use static positioning
  • Take up space in document flow
  • No padding needed
  • Simpler to use, less flexible

Recommendation

Use block for most layouts; reach for absolute only when you need fixed-position label overlay (e.g., compact toolbars).

LB03 Label Content (labelMember & labelCallback)

Automatic label text from object items, plus clickable per-step labels

Live Demo
1. labelMember Property
Product Sizes (labelMember="name"):
Medium
2. labelCallback Function
Subscription Plans (labelCallback):
Basic - $9/mo
3. Clickable Labels (Vertical Mode)
Server Locations:
💡 Try it: Click any city label to jump directly to that server.
Per-step labels become real <button>s when no thumb snippet is provided.
4. Label Priority System
labelMember (highest priority)
Another Label
labelCallback (when no labelMember)
Computed: Fallback 2
Without either: defaults to "Option 1", "Option 2", etc.
Code
 
Feature Details

Object-aware label resolution

Both ways read structured data without writing a snippet.

1. labelMember

  • Extracts label text from an item property
  • Example: labelMember="name" reads item.name
  • Null-safe: skips if property doesn't exist

2. labelCallback

  • Custom function: (item: T, index: number) => string
  • Access to both item data and index
  • Ideal for computed or formatted labels

3. Clickable Labels

  • Available in vertical mode with left/right positions
  • Active when no thumb snippet is provided
  • Renders real <button> elements with keyboard activation

Label Priority

  1. label snippet (full custom)
  2. labelMember (object property)
  3. labelCallback (computed string)
  4. Default: "Option N"

LB04 Custom label snippet

Rich label content via the label snippet (renamed from labelTemplate in 2.0)

Live Demo
Quality Settings:
System Status:
🟡 Connecting
Active
Code
 
Snippet Features

label snippet (v2.0)

The label snippet (renamed from 1.x's labelTemplate) gives full control over per-item label rendering.

Snippet Parameters

  • index — Index of this item (was currentIndex)
  • item — The item data (typed as T | undefined)
  • isSelected — Boolean for selection state

When to Use

  • Multi-line labels with descriptions
  • Icons with text
  • Conditional content based on selection
  • Custom styling per state

LB05 Label Visibility

Control when to show or hide labels

Live Demo
With Labels:
Option 2
Without Labels:
Icons Only (segment snippet):
👍
👎
🤷
Code
 
Visibility Guidelines

When to Hide Labels

  • When space is limited
  • When using self-explanatory icons
  • In compact UI designs
  • When labels are shown elsewhere

Note: segment vs thumb

The icons example uses the segment snippet — it renders once per step background. Use thumb instead if you only want content inside the moving thumb.

Label Best Practices

📝 Content Guidelines
  • ✅ Keep labels concise and clear
  • ✅ Use consistent terminology
  • ✅ Consider internationalization
  • ✅ Test with different text lengths
  • ✅ Ensure sufficient contrast
🎯 Layout Tips
  • ✅ Default to labelRenderMode="block"
  • ✅ Reach for "absolute" only when needed
  • ✅ Use labelMember for simple object items
  • ✅ Use labelCallback for computed strings
  • ✅ Use the label snippet for rich content

Next Steps

🎨
Styling

Per-instance colors with itemStyles

Styling Examples
🌈
Theming

Cross-library --base-* cascade

Theming Guide
📚
API Reference

Complete documentation

MultiSwitch API