<!--
{
  "availability" : [
    "iOS: 15.0.0 -",
    "iPadOS: 15.0.0 -",
    "macCatalyst: 15.0.0 -",
    "macOS: 12.0.0 -",
    "tvOS: 15.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 8.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/View/foregroundStyle(_:_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI4ViewPAAE15foregroundStyleyQrqd___qd_0_tAA05ShapeE0Rd__AaERd_0_r0_lF"
  },
  "title" : "foregroundStyle(_:_:)"
}
-->

# foregroundStyle(_:_:)

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

```
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 [`Color`](/documentation/SwiftUI/Color)
or [`image(_:sourceRect:scale:)`](/documentation/SwiftUI/ShapeStyle/image(_:sourceRect:scale:)), or one of the gradient
types, like
[`linearGradient(colors:startPoint:endPoint:)`](/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 [`primary`](/documentation/SwiftUI/ShapeStyle/primary).

`secondary`

The secondary color or pattern to use when
filling in the foreground elements.

## 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
[`palette`](/documentation/SwiftUI/SymbolRenderingMode/palette) rendering mode when you apply this
modifier, if you don’t explicitly specify another mode.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)