The GaugeStyle
type defines how a gauge is visually represented. By selecting a particular style, you control whether the gauge appears as a ring, a bar, or uses markers to indicate the current value. Some styles only apply on specific platforms (notably watchOS), while others are more broadly available.
A Gauge
component visually represents a value within a specified range. For example, you might use it to show a battery level, download progress, or temperature reading. By combining a Gauge
with a chosen GaugeStyle
, you can tailor the gauge’s appearance to match your app’s design language or functional requirements.
Key points:
automatic
:
Relies on the system’s default style for the current platform and context. This is a good starting point if you don’t have a strong preference.
accessoryCircular
:
Shows an open ring with a marker that points to the current value along the ring’s circumference. Great for showing levels or percentages in a compact, circular form.
accessoryCircularCapacity
:
Similar to accessoryCircular
but shows a closed ring partially filled in up to the current value. This works well to indicate capacity levels, such as a storage meter.
circular
(Only available on watchOS):
Like accessoryCircular
, this displays an open ring with a marker. Useful for watchOS complications or similar small form factor displays.
linearCapacity
:
Displays a horizontal bar that fills from the leading edge to the trailing edge as the value increases. Ideal for progress bars, battery meters, or memory usage indicators.
accessoryLinear
:
A linear gauge that shows a marker along a bar, indicating the exact point of the current value rather than a filled segment.
accessoryLinearCapacity
:
Combines aspects of linearCapacity
with the accessoryLinear
style. It shows a filled bar segment that grows with the value, suitable for showing capacity or progress out of a whole.
linear
(Only available on watchOS):
Similar to accessoryLinear
but watchOS-specific. It shows a marker along a bar for the current value.
In this example, the gauge shows a partially filled circular ring indicating that the battery level is at 70%.
Switching to a linear capacity style:
This would show a horizontal bar filled from left to right up to 70% of its length.
If you prefer a style that shows a marker instead of a fill, you could do:
This style displays an open ring with a marker pointing to the current value (70%) rather than a filled segment.
circular
and accessoryCircular
styles:
Ideal for data that you intuitively represent in a circular format, such as a timer, speedometer-like reading, or capacity shown as a ring.
linear
and accessoryLinear
styles:
Best for data that’s inherently linear, like progress bars, completion percentages, or levels that are typically read left to right.
Capacity
styles:
Perfect for scenarios where you want a filled segment to indicate how “full” or “complete” something is, such as battery life, storage space used, or loading progress.
automatic
:
Let the system decide and adapt style based on context. Good as a default choice if you’re unsure.
By setting the gaugeStyle
on a Gauge
, you have full control over the visual representation of your data. Whether you want a circular ring, a linear bar, a simple marker, or a filled capacity indicator, GaugeStyle
provides flexible options to present information in a way that feels both intuitive and aesthetically pleasing.