How it works
PlainListStyle is the list style that strips a List down to its rows, presenting them without the grouped insets, section backgrounds, or rounded card treatment that other styles apply. It gives you an edge-to-edge, undecorated list that fills its container, which is the right baseline when you want a List's scrolling, selection, and row behavior but want to supply your own visual styling. Reach for it when a list should read as a continuous stream of content rather than a set of inset, decorated groups. You don't instantiate it directly; you select it through the listStyle(_:) modifier using the .plain shorthand.
Start from a List that owns its rows
A list style only takes effect on a List, which provides the scrolling container, row separators, and selection behavior that the style then decorates. Here the
Listholds three rows (Text("Inbox"),Text("Sent"),Text("Drafts")) that PlainListStyle will render without grouping or inset chrome.Apply the style with listStyle(.plain)
Set the appearance by attaching
.listStyle(.plain)to the List. The .plain shorthand resolves to a PlainListStyle value, so you never construct the struct yourself — the modifier accepts any ListStyle and PlainListStyle is the conforming type being selected here.Understand what 'without additional decoration' removes
Compared with inset or grouped styles, PlainListStyle drops the rounded card background and the side insets, letting rows run edge to edge against the list's full width. The rows from the
Listkeep their separators and tappable behavior, but lose the decorative container that .insetGrouped or .grouped would draw around them.Layer your own framing around the plain rows
Because the style intentionally supplies no decoration, surrounding modifiers shape the result. The
.padding()applied after.listStyle(.plain)insets the whole list within its parent, demonstrating that you, not the style, decide the spacing and framing once the rows are presented plainly.
.listStyle(.plain) for .listStyle(.insetGrouped) to see the same rows gain inset side margins and a rounded grouped background — the exact decoration PlainListStyle removes.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 PlainListStyleDemo: View {
var body: some View {
List {
Text("Inbox")
Text("Sent")
Text("Drafts")
}
.listStyle(.plain)
.padding()
}
}