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

# foregroundStyle(_:)

Sets the style of the text displayed by this view.

```
nonisolated func foregroundStyle<S>(_ style: S) -> Text where S : ShapeStyle
```

## Parameters

`style`

The style to use when displaying this text.

## Return Value

A text view that uses the color value you supply.

## Discussion

Use this method to change the rendering style of the text
rendered by a text view.

For example, you can display the names of the colors red,
green, and blue in their respective colors:

```
HStack {
    Text("Red").foregroundStyle(.red)
    Text("Green").foregroundStyle(.green)
    Text("Blue").foregroundStyle(.blue)
}
```

![Three text views arranged horizontally, each containing](images/com.apple.SwiftUI/SwiftUI-Text-foregroundColor@2x.png)

---

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)