31.6 Using the Sidebar List Style
The List instance above is displayed using the default list style. When working with hierarchical lists it is worthwhile noting that a List style is available for this specific purpose in the form of the SidebarListSyle. To see this in action, add a modifier to the List view as follows:
struct ContentView: View {
var body: some View {
List(carItems, children: \.children) { item in
CellView(item: item)
}
.listStyle(SidebarListStyle())
}
}
When previewed, the list will now appear as shown in Figure 31-3, providing a cleaner and more ordered layout than that provided by the default style:
Figure 31-3