.bold()

The .bold() modifier applies a bold style to text characters in a View.

Syntax

struct MyView: View {
    var body: some View {
        Text("I will be bold text!")
            .bold()
    }
}

Inside some View, the .bold() modifier is applied to all text within the Text view.

Example

The following example creates some bold text:

import SwiftUI
struct BoldView: View {
var body: some View {
Text("I'm Bold Text!")
.bold()
}
}

In the above example, the .bold() modifier is called on the Text view. This applies a bold style to all text within the Text view.

This will display:

SwiftUI ViewModifier .bold()

Contributors

Interested in helping build Docs? Read the Contribution Guide or share your thoughts in this feedback form.

Learn SwiftUI on Codecademy