Contents

GaugeStyle

Defines the implementation of all gauge instances within a view hierarchy.

Declaration

@MainActor @preconcurrency protocol GaugeStyle

Overview

To configure the style for all the Gauge instances in a view hierarchy, use the gaugeStyle(_:) modifier. For example, you can configure a gauge to use the circular style:

Gauge(value: batteryLevel, in: 0...100) {
    Text("Battery Level")
}
.gaugeStyle(.circular)

A type conforming to this protocol inherits @preconcurrency @MainActor isolation from the protocol if the conformance is included in the type’s base declaration:

struct MyCustomType: Transition {
    // `@preconcurrency @MainActor` isolation by default
}

Isolation to the main actor is the default, but it’s not required. Declare the conformance in an extension to opt out of main actor isolation:

extension MyCustomType: Transition {
    // `nonisolated` by default
}

Topics

Getting the automatic style

Getting circular gauge styles

Getting linear gauge styles

Creating custom gauge styles

Supporting types

See Also

Styling indicators