Search code examples
swiftui

Set System to always use Rounded Font?


In SwiftUI, is there a way to make the rounded version of the system font the default for all styles? I'm using one of the system styles (.body, .title, .headline, etc) for all text in the app.

For example, I can use this on a single Text view

Text("some text")
    .font(.system(.body, design: .rounded))

I'd like to avoid having to update every text view and field in my app like this. Is there some way to tell the environment to use the rounded design by default?


Solution

  • Starting with iOS 16.1+ and macOS 13.0+, you can apply the fontDesign(_:) modifier to customize the font design in a SwiftUI view hierarchy.

    Here's an example demonstrating how to apply a rounded font design across the entire app:

    import SwiftUI
    
    @main
    struct MyDemoApp: App {
        var body: some Scene {
            WindowGroup {
                ContentView()
                    .fontDesign(.rounded)
            }
        }
    }