SwiftUI Fonts
Anonymous contributor
Published May 18, 2023Updated Oct 5, 2024
Contribute to Docs
Font is a struct that creates Font instances that can be applied to text by passing them to the .font() view modifier.
Font instances can be created using standard fonts, which are type properties of Font. Fonts can also be created and modified using built-in Font methods such as .system(), .italic(), and .bold().
Standard Fonts
Below is a list of some of the standard Font type properties:
.largeTitlea large, title font style..titlea title font style..title2a smaller title font style..title3the smallest title font style..headlinea headline font style..bodythe default font style..footnotea footnote font style..captiona caption font style.
Modifying and Creating Fonts
Below is a list of some of the Font methods used to modify and create fonts:
.bold()applies a bold style..italic()applies an italic style..weight()applies the specified weight style..monospaced()applies a monospaced font style..lowercaseSmallCaps()converts lowercase characters to small capital characters..system(_ style:, design:, weight:)applies a specified font style with optional design and/or weight styles..system(size:, weight:, design:)applies a specified size with optional weight and/or design styles.
It is also possible to create custom fonts using the .custom() method.
Example
The following example shows a VStack containing text views with three different fonts applied:
import SwiftUIstruct FontView: View {let titleFont = Font.largeTitle.lowercaseSmallCaps()let footnoteFont = Font.system(.footnote, design: .serif, weight: .bold)var body: some View {VStack {Text("I Love to See the Summer Beaming Forth").font(titleFont)Text("\nI love to see the summer beaming forth \nAnd white wool sack clouds sailing to the north \nI love to see the wild flowers come again \nAnd mare blobs stain with gold the meadow drain\n").monospaced()Text("- John Clare").font(footnoteFont)}.padding()}}
In the above example:
- The first text view has
titleFontapplied.titleFontis created from the standardFonttype property,.largeTitle, with the method.lowercaseSmallCaps()applied to it. - The next text view has the method
.monospaced()applied, setting the text to use a monospaced font. - The last text view has a created system font
footnoteFontapplied, with a.footnotestyle,.serifdesign, and.boldweight.
This will display:

Contribute to Docs
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.
Learn SwiftUI on Codecademy
- Learn how to build iOS applications with Swift and SwiftUI and publish them to Apples' App Store.
- Includes 7 Courses
- With Certificate
- Beginner Friendly.13 hours
- A powerful programming language developed by Apple for iOS, macOS, and more.
- Beginner Friendly.12 hours