Skip to main content
.foregroundStyle(style: Style)
style
Style
required
A Color, gradient (LinearGradient, RadialGradient, etc.), or Material to apply as the foreground style.

Support

Usage

Color text

Text("Blue text")
    .foregroundStyle(Color("blue"))

System color

Text("Secondary text")
    .foregroundStyle(Color("secondaryLabel"))

Gradient text

Text("Gradient")
    .font("largeTitle")
    .foregroundStyle(LinearGradient({
        colors: ["red", "blue"],
        startPoint: "leading",
        endPoint: "trailing"
    }))

Style a shape

Circle()
    .frame({ width: 50, height: 50 })
    .foregroundStyle(Color("green"))

Inherited by descendants

VStack([
    Text("All text in this stack"),
    Text("will be red")
])
    .foregroundStyle(Color("red"))

See Also