SPB Git

Repository Public MIT

glass-icon-button.md 2.3 KB

# GlassIconButton

Identifier glass-icon-button
Module SPGlassComponents
Kind native-wrapper — a system glass button with a circular border shape
Platforms iOS 26, iPadOS 26, macOS 26
Example Examples/Gallery/Buttons/GlassIconButtonExample.swift

# Minimal usage

swift
GlassIconButton(systemImage: "square.and.arrow.up", accessibilityLabel: "Share") { share() }

# Variants

Variant Use
.regular Secondary actions in toolbars and over content.
.prominent The selected or main action of a group.
role: .destructive Deletion; tinted with the theme's destructive colour.

# Parameters

Parameter Type Default Meaning
systemImage String — SF Symbol name.
accessibilityLabel LocalizedStringKey — Required. Read by VoiceOver, shown as the tooltip on macOS, used by Voice Control.
label Text — Alternative to accessibilityLabel when the text is already a Text.
variant GlassButtonVariant .regular Visual weight.
role ButtonRole? nil System role.
size GlassControlSize .regular Control size.
action @MainActor () -> Void — Called on activation.

# States

Idle, pressed, focused and disabled (.disabled(_:)) are drawn by the system. There is no loading state: replace the symbol or show progress elsewhere.

# Advanced example

swift
GlassIconButton(
    systemImage: isFavourite ? "star.fill" : "star",
    accessibilityLabel: isFavourite ? "Remove from favourites" : "Add to favourites",
    variant: isFavourite ? .prominent : .regular
) { isFavourite.toggle() }
.keyboardShortcut("d", modifiers: .command)

# Accessibility

  • A label is mandatory in the initialiser; a symbol alone is never the accessible name.
  • The tappable area is at least 44 × 44 points on iOS and iPadOS, and 24 × 24 on macOS, at every size.
  • The label is also the tooltip on macOS (.help).
  • State must not rely on the symbol colour alone: change the symbol or the label, as in the example.

# Limits

  • The symbol cannot be rotated or animated through this component; components that need that draw their own glass circle.
  • The glass is drawn by the system and cannot be configured.
Files main
Menu

Theme