How it works
DefaultListStyle resolves to whatever list presentation SwiftUI considers standard for the current platform, version, and surrounding context — for example, an inset-grouped appearance on iOS or a plain sidebar-friendly look on macOS. Reach for it when you want a list to follow the system's default appearance rather than committing to a specific style like .plain, .grouped, or .insetGrouped. It is most useful for explicitly opting back into the default after an ancestor view has imposed a different style, or for documenting in code that the default is the intended choice.
Apply it through the listStyle(_:) modifier
A list style takes effect when you pass it to listStyle(_:) on a List. Here,
.listStyle(DefaultListStyle())attaches the default style to the enclosingList, telling SwiftUI to render its rows and sections with the platform-standard appearance.Instantiate it with DefaultListStyle()
DefaultListStyle is a struct that conforms to ListStyle, and you create an instance with its parameterless initializer,
DefaultListStyle(). It carries no configuration of its own — its entire job is to stand in for the system default, deferring the concrete look to the runtime environment.Use the .automatic shorthand interchangeably
The static member
.automaticon ListStyle is the idiomatic shorthand for the same behavior, so.listStyle(.automatic)produces the result you get from passingDefaultListStyle()directly. Both express the same intent: let SwiftUI choose.Let it shape the list's sections and rows
The chosen style governs how the
Listlays out the content nested inside it — theSection("Today")andSection("Tomorrow")headers and theirLabelrows. With the default style, section grouping, separators, and insets all follow whatever the platform treats as standard for that context.Override an inherited style by reasserting the default
Because a list style applied higher in the view hierarchy flows down to descendant lists, attaching
DefaultListStyle()lets a particular List opt back out and return to the system appearance. Applying it directly on thisListguarantees it renders with the default regardless of any style set by an ancestor.
.listStyle(DefaultListStyle()) with .listStyle(.plain) and watch the section grouping and insets collapse into a flat, edge-to-edge list — then switch it back to see what the platform default restores.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 DefaultListStyleDemo: View {
var body: some View {
List {
Section("Today") {
Label("Buy groceries", systemImage: "cart")
Label("Walk the dog", systemImage: "pawprint")
}
Section("Tomorrow") {
Label("Team standup", systemImage: "person.3")
}
}
.listStyle(DefaultListStyle())
}
}