The .fontWeight() modifier sets the font weight of the text in Text View.


Text("your text")

.weight can be one of the following values:

  • .ultraLight
  • .thin
  • .light
  • .regular
  • .medium
  • .semibold
  • .bold
  • .heavy
  • .black


In the following example, the font weight is set using the .regular and .bold expressions.

import SwiftUI
struct SomeView: View {
var body: some View {
VStack {
Text("Regular Font Weight")
Text("Bold Font Weight")

This will display:

SwiftUI ViewModifier .fontWeight()


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

Learn SwiftUI on Codecademy