0Pricing
SwiftUI Academy · Lesson

Sections & List Styles

Group rows with sections and pick a list style.

Sections & List Styles is a free SwiftUI Academy lesson on CoddyKit — lesson 4 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the SwiftUI Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.

Grouping with Sections

A long list reads better when split into chunks. Section groups related rows under a shared heading. 🗂️

List {
    Section("Fruits") {
        Text("Apple")
    }
}

Headers and Footers

A Section can show a header above its rows and a footer below, great for titles and helper text.

Section {
    Text("Wi-Fi")
} header: {
    Text("Network")
} footer: {
    Text("Tap to connect")
}

Multiple Sections

Stack several Section blocks in one List to organize a busy screen into clear, labeled groups that are easy to scan.

List {
    Section("On") { Text("Item A") }
    Section("Off") { Text("Item B") }
}

Sections With ForEach

Combine Section with ForEach to build grouped, data-driven lists, like contacts sorted by letter.

Section("A") {
    ForEach(aNames, id: \.self) { Text($0) }
}

Meet List Styles

The listStyle modifier changes a list's whole look, from grouped cards to plain edge-to-edge rows.

List { Text("Row") }
    .listStyle(.insetGrouped)

The Inset Grouped Look

insetGrouped is the default rounded-card style you see in Settings, with spacing around each section.

.listStyle(.insetGrouped)

The Plain Style

The plain style removes the card insets for full-width, edge-to-edge rows, ideal for feeds and chat-like screens.

.listStyle(.plain)

The Grouped Style

The grouped style gives boxed sections without the rounded inset corners, a classic full-width table look.

.listStyle(.grouped)

Styling Section Headers

You can restyle a header with modifiers, changing its font, color, or case to match your design.

header: {
    Text("Network").font(.headline)
}

Collapsible Sections

A header can act as a control too, letting you build expandable sections that show or hide their rows.

Pick the Right Style

Choose a style that fits the screen: insetGrouped for settings, plain for content feeds. The data stays the same. ✨

Quick Check

Match each concept to its job.

Recap

You learned Section and listStyle: group rows into labeled chunks and switch looks like insetGrouped or plain. 🎉

Frequently asked questions

Is the “Sections & List Styles” lesson free?

Yes — the full text of “Sections & List Styles” is free to read here on the web, and the SwiftUI Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the SwiftUI Academy course, upgrade to CoddyKit PRO.

What will I learn in “Sections & List Styles”?

Group rows with sections and pick a list style. You practise SwiftUI Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start SwiftUI Academy?

No prior experience is required. SwiftUI Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 4 of 4, so you can start here or from the beginning and move at your own pace.

How long does the “Sections & List Styles” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this SwiftUI Academy lesson?

Yes. Every SwiftUI Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

All lessons in this course

  1. Building a Static List
  2. Looping with ForEach
  3. Identifiable & Stable IDs
  4. Sections & List Styles
← Back to SwiftUI Academy