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

# foregroundStyle(_:)

Sets the style of the text displayed by this view.

## Declaration

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

## Parameters

- `style`: The style to use when displaying this text.

## Return Value

Return Value A text view that uses the color value you supply.

## Discussion

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) }

## See Also

### Styling the view’s text

- [bold()](swiftui/text/bold().md)
- [bold(_:)](swiftui/text/bold(_:).md)
- [italic()](swiftui/text/italic().md)
- [italic(_:)](swiftui/text/italic(_:).md)
- [strikethrough(_:color:)](swiftui/text/strikethrough(_:color:).md)
- [strikethrough(_:pattern:color:)](swiftui/text/strikethrough(_:pattern:color:).md)
- [underline(_:color:)](swiftui/text/underline(_:color:).md)
- [underline(_:pattern:color:)](swiftui/text/underline(_:pattern:color:).md)
- [monospaced(_:)](swiftui/text/monospaced(_:).md)
- [monospacedDigit()](swiftui/text/monospaceddigit().md)
- [kerning(_:)](swiftui/text/kerning(_:).md)
- [tracking(_:)](swiftui/text/tracking(_:).md)
- [baselineOffset(_:)](swiftui/text/baselineoffset(_:).md)
- [Text.Case](swiftui/text/case.md)
- [Text.DateStyle](swiftui/text/datestyle.md)
