SP GlassKit1.1.0

GlassButton

Button using the system glass styles, with destructive role, loading and disabled states.

  • System control
  • iOS 26 · iPadOS 26 · macOS 26
  • Version 1.1.0
  • glass-button

Drawn by the system. GlassKit configures it and leaves the glass to the system.

GlassButton running in SP Glass Studio.Capture
Capture of the component running in SP Glass Studio on the iOS 26.5 simulator. Liquid Glass is rendered by the system; this is an image, not a live preview.

Installation

spglass add glass-button

Copies the sources and their dependencies into your project. Set up the CLI.

Swift
.package(url: "https://git.spboucher.ai/sp-glasskit.git", from: "1.1.0")

import SPGlassKit
Identifierglass-button
ModuleSPGlassComponents
Kindnative-wrapper — the system draws the button with .buttonStyle(.glass) or .glassProminent
PlatformsiOS 26, iPadOS 26, macOS 26
ExampleExamples/Gallery/Buttons/GlassButtonExample.swift

Minimal usage

Swift
GlassButton("Save") { save() }

Variants

VariantUse
.regularMost actions. Untinted system glass.
.prominentThe main action of a view, filled with the theme's primary colour. One per view at most.
role: .destructiveDeletion and other irreversible actions. Tinted with the theme's destructive colour; the system also announces the role.

Sizes are .small, .regular and .large; they map to the system ControlSize, so the button keeps the metrics of the platform.

Parameters

ParameterTypeDefaultMeaning
titleKeyLocalizedStringKey—Title, looked up in the host application's strings.
verbatimStringProtocol—Title that is already a string (data, user content).
systemImageString?nilSF Symbol shown before the title. Hidden while loading.
variantGlassButtonVariant.regularVisual weight.
roleButtonRole?nilSystem role (.destructive, .cancel).
sizeGlassControlSize.regularControl size.
isLoadingBoolfalseShows a progress indicator and ignores taps.
action@MainActor () -> Void—Called on activation.
label@ViewBuilder—Custom label, instead of a title.

States

Idle, pressed and focused are drawn by the system. disabled is the standard .disabled(_:) modifier. loading is isLoading: the action cannot be triggered and VoiceOver reads "Loading" as the value of the button.

Advanced example

Swift
GlassButton(variant: .prominent, size: .large, isLoading: model.isUploading) {
    model.upload()
} label: {
    VStack(alignment: .leading) {
        Text("Upload")
        Text(model.fileName).font(.caption)
    }
}
.keyboardShortcut(.defaultAction)

Accessibility

  • The title is the accessibility label; a custom label must contain text or set .accessibilityLabel.
  • The label of a prominent button stays legible on a light fill: when the theme's primary (or destructive) colour is pale in the current appearance, as in Obsidian's dark appearance, the label takes a near-black instead of the system's white (GlassButtonContrast holds the rule: white is kept while its contrast on the fill is at least 2.5). glassButtonLabelContrast(_:role:) applies the same rule to a label of your own.
  • Text follows Dynamic Type and wraps instead of truncating.
  • The loading state is exposed as an accessibility value, not by the spinner alone.
  • The destructive role is conveyed by the system role, not only by colour.

Limits

  • The glass itself (blur, refraction, highlights) is drawn by the system and cannot be configured.
  • A simulated Reduce Transparency (glassSimulatedAccessibility) switches to the bordered system styles; the real setting is handled by the system inside the glass styles.
  • Several prominent buttons side by side weaken the hierarchy; prefer one.

Example

Complete example (compiled with the package)
import SwiftUI
import SPGlassKit

public struct GlassButtonExample: GlassExample {
    public static let componentID = "glass-button"
    @State private var isSaving = false
    @State private var saveCount = 0

    public init() {}

    public var body: some View {
        VStack(spacing: 16) {
            GlassButton("Save changes", systemImage: "checkmark", variant: .prominent, isLoading: isSaving) {
                isSaving = true
                saveCount += 1
            }
            GlassButton("Duplicate", systemImage: "plus.square.on.square") { saveCount += 1 }
            GlassButton("Delete draft", systemImage: "trash", role: .destructive) { saveCount = 0 }
            GlassButton("Unavailable", size: .small) {}
                .disabled(true)
            GlassButton(variant: .regular, size: .large) {
                isSaving = false
            } label: {
                VStack {
                    Text("Reset")
                    Text("Saved \(saveCount) times").font(.caption)
                }
            }
        }
        .padding()
    }
}

#Preview("GlassButton") { GlassButtonExample().glassTheme(.aurora) }

Registry entry

Identifierglass-button
Version1.1.0
Depends onglass-components-support, glass-foundation
FrameworksSwiftUI
Public symbolsGlassButton, GlassButtonLabel
LicenceMIT
Manifestmanifest.json

Files