SP GlassKit1.1.0

GlassProgress

Determinate or indeterminate system progress with an optional cancel action.

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

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

GlassProgress 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-progress

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-progress
ModuleSPGlassComponents
Kindnative-wrapper — the system ProgressView; the theme only sets the tint
PlatformsiOS 26, iPadOS 26, macOS 26
ExampleExamples/Gallery/Feedback/GlassProgressExample.swift

Minimal usage

Swift
GlassProgress("Uploading", value: uploadedBytes, total: totalBytes)

Variants

VariantUse
Determinatevalue: and total:; shows the percentage unless showsPercent is false.
IndeterminateNo value: GlassProgress("Connecting").
.linear (default)Label and percentage above a bar.
.circularRing (determinate) or spinner (indeterminate) before the label.
onCancel:Adds a cancel button.

Parameters

ParameterTypeDefaultMeaning
labelLocalizedStringKey? or Text?nilWhat is in progress.
valueDouble—Completed amount, clamped to 0...total.
totalDouble1Amount that means "finished".
fractionDouble?—Alternative to value/total; nil is indeterminate.
styleGlassProgressStyle.linearShape of the indicator.
showsPercentBooltrueShows the percentage (determinate only).
onCancel(@MainActor () -> Void)?nilShows the cancel button.

GlassProgressMath.fraction(value:total:) returns 0 for a total that is zero, negative or not finite and for a value that is not finite; otherwise the ratio clamped to 0...1. percentText(_:locale:) formats with FormatStyle ("42%", "42 %").

Styles

StyleAppearance
.linearA capsule bar under the label and the percentage.
.circularA small ring next to the label; a turning arc when indeterminate.
.ringA large ring with the percentage in its centre and the label underneath.
.stepsOne segment per step: GlassProgress("Shipping address", step: 2, of: 4) shows "2 / 4".

The indicator stays the native ProgressView, drawn by a GlassKit ProgressViewStyle in the theme's primary colour. With Reduce Motion the indeterminate bar and arc stop moving. GlassProgressMath.steps(_:of:) and completedSegments(fraction:count:) are pure and public. VoiceOver reads a stepped indicator as a percentage.

States

Determinate (0 to 100 %) or indeterminate. The component does not decide completion: the host removes it or replaces it when the work is done or cancelled.

Advanced example

Swift
switch download.state {
case .preparing:
    GlassProgress("Preparing", style: .circular, onCancel: { download.cancel() })
case .running(let received, let expected):
    GlassProgress(label: Text(download.fileName), fraction: GlassProgressMath.fraction(value: received, total: expected),
                  onCancel: { download.cancel() })
case .finished:
    GlassBanner(.success, title: "Download complete")
}

Accessibility

  • The indicator and its label are one element: label (or "Loading" when none), value "42 percent" (or "Loading" when indeterminate), with the updates-frequently trait.
  • The cancel button is a separate element labelled "Cancel" with the minimum hit target.
  • The percentage uses monospaced digits so the label does not shift as the value changes.

Limits

  • The bar, ring and spinner are drawn by the system; their size follows .controlSize(_:), not a GlassKit parameter.
  • No estimated time remaining and no automatic completion state.
  • A spinner animates for as long as it is on screen; remove indeterminate indicators when nothing is in progress.

Example

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

public struct GlassProgressExample: GlassExample {
    public static let componentID = "glass-progress"
    @State private var uploaded = 30.0
    @State private var isCancelled = false

    public init() {}

    public var body: some View {
        VStack(alignment: .leading, spacing: 20) {
            if isCancelled {
                Text("Upload cancelled").foregroundStyle(.secondary)
            } else {
                GlassProgress("Uploading sample.pdf", value: uploaded, total: 120, onCancel: { isCancelled = true })
            }
            GlassProgress("Storage used", value: 0.82, style: .circular)
            GlassProgress("Connecting")
            GlassProgress(style: .circular)
            HStack(spacing: 24) {
                GlassProgress("Storage", value: 0.82, style: .ring)
                GlassProgress("Battery", value: 0.46, style: .ring)
            }
            GlassProgress("Shipping address", step: 2, of: 4)
            HStack {
                GlassButton("Add 30 MB") { uploaded += 30 }
                GlassButton("Restart") {
                    uploaded = 0
                    isCancelled = false
                }
            }
        }
        .padding()
    }
}

#Preview("GlassProgress") { GlassProgressExample() }

Registry entry

Identifierglass-progress
Version1.1.0
Depends onglass-foundation
FrameworksSwiftUI
Public symbolsGlassProgressStyle, GlassProgressMath, GlassProgress
LicenceMIT
Manifestmanifest.json

Files