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.
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.Select the style with .automatic
The style is requested through the
.automaticshorthand, which resolves to anAutomaticLabeledContentStyleinstance. It is the value you pass when you want SwiftUI's context-driven default rather than a hand-built layout.Apply it with labeledContentStyle(_:)
The
.labeledContentStyle(.automatic)modifier installs the style on the view and propagates it down through the environment, so everyLabeledContentin the subtree adopts it. Attaching it to theFormstyles all three rows at once rather than each row individually.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.
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.
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()
}
}