SwiftUI.js
Components

Label

Label is a view that displays an icon and a title. Label provides a consistent way to display icon-text combinations, commonly used in navigation items and lists.

Label is a view that displays an icon and a title. Label provides a consistent way to display icon-text combinations, commonly used in navigation items and lists.

Examples

Basic Usage

Preview unavailable for this example in the static docs build.

Show code
<Label icon="🏠" title="Home"></Label>

Icon Only

Preview unavailable for this example in the static docs build.

Show code
<Label icon="⭐" title="Favorites" variant="iconOnly"></Label>

Title Only

Preview unavailable for this example in the static docs build.

Show code
<Label icon="⚙️" title="Settings" variant="titleOnly"></Label>

API

PropTypeRequiredDescription
iconReactNodeNoLabel icon
titlestringYesLabel text
variant'automatic' | 'iconOnly' | 'titleOnly'NoLabel style variant Default: 'automatic'
styleIBaseComponent['style']NoCustom CSS style (overrides variant)

Inherits additional props from Omit<IBaseComponent, 'style'>.

Overview

Label is a view that displays an icon and a title. Label provides a consistent way to display icon-text combinations, commonly used in navigation items and lists.

SwiftUI Correspondence: Similar to SwiftUI's Label.

Variants

Label supports different display variants:

Notes

  • Label requires icon and title props
  • Label supports different variants: default, iconOnly, titleOnly
  • Label provides consistent spacing and alignment
  • Use Label for navigation items, list items, and menu items
  • Label automatically handles icon and text alignment

Best Practices

  1. Icons: Use appropriate icons that match the label meaning
  2. Consistency: Use Label consistently for icon-text combinations
  3. Accessibility: Ensure labels are accessible with proper text
  4. Variants: Choose appropriate variant for your use case
  5. Spacing: Label provides consistent spacing automatically

On this page