.bold()

Published Jan 5, 2023Updated Mar 17, 2023
Contribute to Docs

The .bold() modifier method applies a bold font weight to text.

Syntax

Text("I will be bold text!")
    .bold()

The .bold() modifier takes no parameters and returns a Text view with bold text.

Example

The following example creates bolded text:

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

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

This will display the following:

SwiftUI ViewModifier .bold()

All contributors

Looking to contribute?

Learn SwiftUI on Codecademy