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

# foregroundColor(_:)

Sets the color of the text displayed by this view.

## Declaration

```swift
nonisolated func foregroundColor(_ color: Color?) -> Text
```

## Parameters

- `color`: The color 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 color 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").foregroundColor(.red)     Text("Green").foregroundColor(.green)     Text("Blue").foregroundColor(.blue) }
