foregroundStyle

Sets the primary, secondary, and tertiary levels of the foreground style.

View ModifieriOS 15.0+macOS 12.0+tvOS 15.0+watchOS 8.0+

Overloads

3 ways to call compose().foregroundStyle(). Each is one SwiftUI overload, picked by the arguments you pass.

React
compose().foregroundStyle(
  primary: SwiftUI.ShapeStyle,
  secondary: SwiftUI.ShapeStyle,
  tertiary: SwiftUI.ShapeStyle
)
Swift
nonisolated func foregroundStyle<S1, S2, S3>(
    _ primary: S1,
    _ secondary: S2,
    _ tertiary: S3
) -> some View
where S1 : ShapeStyle, S2 : ShapeStyle, S3 : ShapeStyle

Parameters

Return value

A view that uses the given foreground styles.

Discussion

SwiftUI uses these styles when rendering child views that don't have an explicit rendering style, like images, text, shapes, and so on.

Symbol images within the view hierarchy use the SymbolRenderingMode.palette rendering mode when you apply this modifier, if you don't explicitly specify another mode.

See also

More in Styles.