SwiftUI – Text Font Weight
To set font weight for text in Text view, call fontWeight() method on this Text view and pass required font weight to the method. fontWeight() sets the specified font weight to the text in Text view.
Possible values for the font weight are
- black
- bold
- heavy
- light
- medium
- regular
- semibold
- thin
- ultraLight
Example
In the following example, we created a Text view, and set the font weight with heavy.
ContentView.swift
import SwiftUI
struct ContentView: View {
var body: some View {
Text("Hello, world!")
.fontWeight(.heavy)
}
}
Screenshot

This is how a heavy font weight looks.
Now let us create some Text views with different font weight values.
ContentView.swift
import SwiftUI
struct ContentView: View {
var body: some View {
Text("Black Text")
.fontWeight(.black)
Text("Bold Text")
.fontWeight(.bold)
Text("Heavy Text")
.fontWeight(.heavy)
Text("Light Text")
.fontWeight(.light)
Text("Medium Text")
.fontWeight(.medium)
Text("Regular Text")
.fontWeight(.regular)
Text("Semi-bold Text")
.fontWeight(.semibold)
Text("Thin Text")
.fontWeight(.thin)
Text("Ultra-light Text")
.fontWeight(.ultraLight)
}
}
Screenshot

Summary
Summarising this SwiftUI Tutorial, we learned how to set font weight to the text in Text view.