TechnologiesSwiftUILists and Collections

DefaultListStyle struct

iOSmacOStvOSwatchOSvisionOSiOS 13.0+✓ renders

The list style that describes a platform's default behavior and appearance

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.

  1. 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 enclosing List, telling SwiftUI to render its rows and sections with the platform-standard appearance.

  2. 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.

  3. Use the .automatic shorthand interchangeably

    The static member .automatic on ListStyle is the idiomatic shorthand for the same behavior, so .listStyle(.automatic) produces the result you get from passing DefaultListStyle() directly. Both express the same intent: let SwiftUI choose.

  4. Let it shape the list's sections and rows

    The chosen style governs how the List lays out the content nested inside it — the Section("Today") and Section("Tomorrow") headers and their Label rows. With the default style, section grouping, separators, and insets all follow whatever the platform treats as standard for that context.

  5. 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 this List guarantees it renders with the default regardless of any style set by an ancestor.

Try it — Replace .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.

DefaultListStyle.swift
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())
    }
}
Live preview
Today Buy groceries Walk the dog Tomorrow Team standup
Today Buy groceries Walk the dog Tomorrow Team standup
swift → lexer → parser → sema → uiir → canvas Open in Studio ↗
What's new in SwiftUI 27 →