Chapter 43
Using Gauge to Display Progress and Create a Speedometer
SwiftUI offers a powerful view called Gauge for displaying progress. This versatile component allows you to visually represent any values within a specified range. In this chapter, we'll explore how to effectively use the Gauge view and work with its various styles to create intuitive and visually appealing progress indicators in your iOS applications.
A gauge is a view that shows a current level of a value in relation to a specified finite capacity, very much like a fuel gauge in an automobile. Gauge displays are configurable; they can show any combination of the gauge’s current value, the range the gauge can display, and a label describing the purpose of the gauge itself.
- Apple's official documentation
The simplest way to use Gauge is like this:
struct ContentView: View {
@State private var progress = 0.5
var body: some View {
Gauge(value: progress) {
Text("Upload Status")
}
}
}
In the most basic form, a gauge has a default range from 0 to 1. If we set the value parameter to 0.5, SwiftUI renders a progress bar indicating the task is 50% complete.

Optionally, you can provide labels for the current, minimum, and maximum values:
To access the full content and the complete source code, please get your copy at https://www.appcoda.com/swiftui.