0Pricing
SwiftUI Academy · Lesson

Dynamic Type & Scaled Fonts

Support larger text without breaking layout.

Dynamic Type & Scaled Fonts is a free SwiftUI Academy lesson on CoddyKit — lesson 2 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the SwiftUI Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.

What Is Dynamic Type?

Dynamic Type lets users pick their preferred text size system-wide. Your app should respect it, not force one fixed size. 🔤

Use Text Styles

Pick semantic text styles like .title or .body instead of fixed point sizes. These scale automatically with the user's setting.

Text("Welcome")
    .font(.title)
Text("Details here")
    .font(.body)

Why Not Fixed Sizes

A hard-coded .font(.system(size: 17)) ignores the user's choice and stays small. Text styles adapt; fixed numbers don't.

Text("Stuck small")
    .font(.system(size: 17))

Scaling Custom Fonts

Have a brand font? Use .font(.custom:size:relativeTo:) so it still scales with a chosen text style.

Text("Brand")
    .font(.custom("Avenir", size: 17, relativeTo: .body))

The ScaledMetric Wrapper

Need a spacing or image size to grow with text? @ScaledMetric scales any number alongside Dynamic Type.

@ScaledMetric var iconSize = 24
Image(systemName: "star").frame(width: iconSize)

Let Text Wrap

Big text needs room. Avoid lineLimit(1) on important labels, or long words will be cut off with an ellipsis.

Text(longTitle)
    .lineLimit(2)

Allow Tighter Fitting

When space is truly tight, minimumScaleFactor lets text shrink a little before truncating, keeping it readable.

Text(price)
    .minimumScaleFactor(0.7)

Preview Large Sizes

Use dynamicTypeSize in a preview to simulate the largest setting and catch broken layouts early.

#Preview {
    ContentView()
        .dynamicTypeSize(.accessibility3)
}

Cap the Range If Needed

You can limit how far text scales with dynamicTypeSize(...), but cap sparingly so you don't shut out users who need more.

VStack { }
    .dynamicTypeSize(...DynamicTypeSize.accessibility1)

Stacks Over Fixed Frames

Prefer flexible stacks over rigid heights. A fixed frame can clip large text, while a stack grows to fit.

Test at Both Ends

Check your app at the smallest and the largest Dynamic Type sizes. If both read well, most users in between will too.

Quick Check

You want a custom brand font to grow with the user's text size. What do you use?

Recap

You made text adapt: choose semantic text styles, scale custom fonts and metrics, let text wrap, and test the largest size. 👍

Frequently asked questions

Is the “Dynamic Type & Scaled Fonts” lesson free?

Yes — the full text of “Dynamic Type & Scaled Fonts” is free to read here on the web, and the SwiftUI Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the SwiftUI Academy course, upgrade to CoddyKit PRO.

What will I learn in “Dynamic Type & Scaled Fonts”?

Support larger text without breaking layout. You practise SwiftUI Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start SwiftUI Academy?

No prior experience is required. SwiftUI Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 2 of 4, so you can start here or from the beginning and move at your own pace.

How long does the “Dynamic Type & Scaled Fonts” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this SwiftUI Academy lesson?

Yes. Every SwiftUI Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

All lessons in this course

  1. VoiceOver & Accessibility Labels
  2. Dynamic Type & Scaled Fonts
  3. Localizing Strings & String Catalogs
  4. Adapting to Light & Dark Mode
← Back to SwiftUI Academy