3 min readMar 13, 2026
SwiftHow to Build a List in SwiftUI
Render a list from an array.
Steps
- Paste the view into a SwiftUI file.
- Set it as a preview or root view.
- Update state or bindings to match your data.
Copy and paste
import SwiftUI
struct ListView: View {
let items = ["One", "Two", "Three"]
var body: some View {
List(items, id: .self) { item in
Text(item)
}
}
}Notes
- Use @State for local values and bindings for child views.
- Extract subviews when the body grows.
