Contents

DynamicTypeSize

A Dynamic Type size, which specifies how large scalable content should be.

Declaration

enum DynamicTypeSize

Overview

Read this value from the environment to adapt a layout to the text size someone chooses in system settings. The sizes are ordered, so you can compare them to find out how much room the text needs.

struct BatteryLabel: View {
    @Environment(\.dynamicTypeSize) private var dynamicTypeSize

    var body: some View {
        if dynamicTypeSize >= .accessibility1 {
            VStack {
                BatteryIcon()
                Text("Charging")
            }
        } else {
            HStack {
                BatteryIcon()
                Text("Charging")
            }
        }
    }
}

The five sizes whose names begin with accessibility are much larger than the rest. Check isAccessibilitySize when you want to change a layout for those sizes without comparing sizes yourself.

For more information, see Typography in the Human Interface Guidelines.

Topics

Getting type sizes

Getting accessibility type sizes

Creating a type size

See Also

Adjusting text size