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.
CaptureInstallation
spglass add glass-progressCopies the sources and their dependencies into your project. Set up the CLI.
.package(url: "https://git.spboucher.ai/sp-glasskit.git", from: "1.1.0")
import SPGlassKit| Identifier | glass-progress |
|---|---|
| Module | SPGlassComponents |
| Kind | native-wrapper — the system ProgressView; the theme only sets the tint |
| Platforms | iOS 26, iPadOS 26, macOS 26 |
| Example | Examples/Gallery/Feedback/GlassProgressExample.swift |
Minimal usage
GlassProgress("Uploading", value: uploadedBytes, total: totalBytes)Variants
| Variant | Use |
|---|---|
| Determinate | value: and total:; shows the percentage unless showsPercent is false. |
| Indeterminate | No value: GlassProgress("Connecting"). |
.linear (default) | Label and percentage above a bar. |
.circular | Ring (determinate) or spinner (indeterminate) before the label. |
onCancel: | Adds a cancel button. |
Parameters
| Parameter | Type | Default | Meaning |
|---|---|---|---|
label | LocalizedStringKey? or Text? | nil | What is in progress. |
value | Double | — | Completed amount, clamped to 0...total. |
total | Double | 1 | Amount that means "finished". |
fraction | Double? | — | Alternative to value/total; nil is indeterminate. |
style | GlassProgressStyle | .linear | Shape of the indicator. |
showsPercent | Bool | true | Shows the percentage (determinate only). |
onCancel | (@MainActor () -> Void)? | nil | Shows 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
| Style | Appearance |
|---|---|
.linear | A capsule bar under the label and the percentage. |
.circular | A small ring next to the label; a turning arc when indeterminate. |
.ring | A large ring with the percentage in its centre and the label underneath. |
.steps | One 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
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
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
| Identifier | glass-progress |
|---|---|
| Version | 1.1.0 |
| Depends on | glass-foundation |
| Frameworks | SwiftUI |
| Public symbols | GlassProgressStyle, GlassProgressMath, GlassProgress |
| Licence | MIT |
| Manifest | manifest.json |
Files
Components/Feedback/GlassProgress.swift14859 bytes · sha256 522ad99d9af9…