TechnologiesSwiftUI

AutomaticLabeledContentStyle struct

iOSmacOStvOSwatchOSvisionOSiOS 16.0+✓ renders

The default labeled content style.

How it works

AutomaticLabeledContentStyle is the default style SwiftUI applies to every LabeledContent view, resolving its appearance from the surrounding context rather than a fixed layout. It pairs a label with its associated value and arranges them the way the enclosing container expects — for instance, leading the label and trailing the value inside a Form row. Reach for it when you want labeled rows that simply look correct in whatever container they sit in, without committing to a custom presentation. Because it is the style already in force, you typically name it only to make the default explicit or to reset a more specific style back to standard behavior.

  1. Let LabeledContent supply a label and value

    AutomaticLabeledContentStyle operates on a LabeledContent view, which is the thing being styled. Each row here gives a title and an associated value, as in LabeledContent("Battery", value: "82%"), and the style decides how that pair is laid out and aligned.

  2. Select the style with .automatic

    The style is requested through the .automatic shorthand, which resolves to an AutomaticLabeledContentStyle instance. It is the value you pass when you want SwiftUI's context-driven default rather than a hand-built layout.

  3. Apply it with labeledContentStyle(_:)

    The .labeledContentStyle(.automatic) modifier installs the style on the view and propagates it down through the environment, so every LabeledContent in the subtree adopts it. Attaching it to the Form styles all three rows at once rather than each row individually.

  4. Let the container shape the resolved layout

    Because the style is automatic, it reads its presentation from the context it lands in. Inside the Form, that means the standard inset-grouped row treatment — label leading, value trailing — without any explicit alignment code in the demo.

Try it — Wrap the rows in an HStack instead of the Form and keep .labeledContentStyle(.automatic) to watch the resolved layout shift from a Form-style row to a plain label-and-value pairing.

Example & preview

Press Run live & edit to compile it in your browser — then edit the Swift on the left and the preview re-renders live.

AutomaticLabeledContentStyle.swift
struct AutomaticLabeledContentStyleDemo: View {
    var body: some View {
        Form {
            LabeledContent("Battery", value: "82%")
            LabeledContent("Network", value: "Wi-Fi")
            LabeledContent("Storage", value: "128 GB")
        }
        .labeledContentStyle(.automatic)
        .padding()
    }
}
Live preview
Battery 82% Network Wi-Fi Storage 128 GB
Battery 82% Network Wi-Fi Storage 128 GB
swift → lexer → parser → sema → uiir → canvas Open in Studio ↗
What's new in SwiftUI 27 →