GlassProgress
| 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
swift
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 %").
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.