---
title: "foregroundStyle(_:_:)"
framework: swiftui
role: symbol
role_heading: Instance Method
path: "swiftui/view/foregroundstyle(_:_:)"
---

# foregroundStyle(_:_:)

Sets the primary and secondary levels of the foreground style in the child view.

## Declaration

```swift
nonisolated func foregroundStyle<S1, S2>(_ primary: S1, _ secondary: S2) -> some View where S1 : ShapeStyle, S2 : ShapeStyle

```

## Parameters

- `primary`: The primary color or pattern to use when filling in the foreground elements. To indicate a specific value, use doc://com.apple.SwiftUI/documentation/SwiftUI/Color or doc://com.apple.SwiftUI/documentation/SwiftUI/ShapeStyle/image(_:sourceRect:scale:), or one of the gradient types, like doc://com.apple.SwiftUI/documentation/SwiftUI/ShapeStyle/linearGradient(colors:startPoint:endPoint:). To set a style that’s relative to the containing view’s style, use one of the semantic styles, like doc://com.apple.SwiftUI/documentation/SwiftUI/ShapeStyle/primary.
- `secondary`: The secondary color or pattern to use when filling in the foreground elements.

## Return Value

Return Value A view that uses the given foreground styles.

## Discussion

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 palette rendering mode when you apply this modifier, if you don’t explicitly specify another mode.

## See Also

### Styling content

- [border(_:width:)](swiftui/view/border(_:width:).md)
- [foregroundStyle(_:)](swiftui/view/foregroundstyle(_:).md)
- [foregroundStyle(_:_:_:)](swiftui/view/foregroundstyle(_:_:_:).md)
- [backgroundStyle(_:)](swiftui/view/backgroundstyle(_:).md)
- [backgroundStyle](swiftui/environmentvalues/backgroundstyle.md)
- [ShapeStyle](swiftui/shapestyle.md)
- [AnyShapeStyle](swiftui/anyshapestyle.md)
- [Gradient](swiftui/gradient.md)
- [MeshGradient](swiftui/meshgradient.md)
- [AnyGradient](swiftui/anygradient.md)
- [ShadowStyle](swiftui/shadowstyle.md)
- [Glass](swiftui/glass.md)
