# SwiftUI: the List view

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

Author: Flavio Copes | Published: 2021-09-22 | Canonical: https://flaviocopes.com/swiftui-list/

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

```swift
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](https://flaviocopes.com/images/swiftui-list/Screen_Shot_2021-09-21_at_18.08.11.png)

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](https://flaviocopes.com/images/swiftui-list/Screen_Shot_2021-09-21_at_18.07.05.png)

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](https://flaviocopes.com/images/swiftui-list/Screen_Shot_2021-09-21_at_18.33.10.png)

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

- `InsetGroupedListStyle`
- `InsetListStyle`
* `SidebarListStyle`
* `GroupedListStyle`
* `PlainListStyle`

For example here's `InsetGroupedListStyle`:

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

![iPhone simulator showing SwiftUI List with InsetGroupedListStyle applied, displaying rounded inset sections](https://flaviocopes.com/images/swiftui-list/Screen_Shot_2021-09-21_at_18.37.30.png)

And here's `GroupedListStyle`:

```swift
List {
		//...
}.listStyle(GroupedListStyle())
```
![iPhone simulator showing SwiftUI List with GroupedListStyle applied, displaying grouped sections](https://flaviocopes.com/images/swiftui-list/Screen_Shot_2021-09-21_at_18.34.26.png)

Here's `SidebarListStyle`:

![iPhone simulator showing SwiftUI List with SidebarListStyle applied, displaying collapsible sections with dropdown arrows](https://flaviocopes.com/images/swiftui-list/Screen_Shot_2021-09-21_at_18.38.36.png)
