Skip to content
FLAVIO COPES
flaviocopes.com
2026

SwiftUI: the List view

By Flavio Copes

Learn how to use the List view in SwiftUI to show data in rows, group items with the Section view, and change its look with the listStyle modifier.

~~~

The List view is one of the most useful views you’ll use in SwiftUI.

List {
            
}

Inside it, you can put a series of views, like Text for example:

Xcode showing SwiftUI List with single Text element and iPhone simulator displaying One in a list row

See? List recognizes the Text child view, and puts it inside a row.

You can put more than one, and each child of List will be put on its own row:

Xcode showing SwiftUI List with three Text elements and iPhone simulator displaying One, Two, Three in separate rows

Inside a list, you can group items using the Section view, like this:

Xcode showing SwiftUI List with Section views and iPhone simulator displaying items grouped under FIRST 2 and OTHERS headers

The listStyle() modifier of List can let you customize the List appearance, using

For example here’s InsetGroupedListStyle:

List {
		//...
}.listStyle(InsetGroupedListStyle())

iPhone simulator showing SwiftUI List with InsetGroupedListStyle applied, displaying rounded inset sections

And here’s GroupedListStyle:

List {
		//...
}.listStyle(GroupedListStyle())

iPhone simulator showing SwiftUI List with GroupedListStyle applied, displaying grouped sections

Here’s SidebarListStyle:

iPhone simulator showing SwiftUI List with SidebarListStyle applied, displaying collapsible sections with dropdown arrows

Tagged: Swift · All topics
~~~

Related posts about swift: