A Color, gradient (LinearGradient, RadialGradient, etc.), or Material to apply as the foreground style.
Sets the foreground style (text color, shape fill, etc.) for a component and its descendants.
.foregroundStyle(style: Style)
Text("Blue text")
.foregroundStyle(Color("blue"))
Text("Secondary text")
.foregroundStyle(Color("secondaryLabel"))
Text("Gradient")
.font("largeTitle")
.foregroundStyle(LinearGradient({
colors: ["red", "blue"],
startPoint: "leading",
endPoint: "trailing"
}))
Circle()
.frame({ width: 50, height: 50 })
.foregroundStyle(Color("green"))
VStack([
Text("All text in this stack"),
Text("will be red")
])
.foregroundStyle(Color("red"))