Reference — SwiftUI stacks, grids, outlines, and scroll enhancements through iOS 26
View on GitHubCharlesWiltgen/Axiom
axiom
.claude-plugin/plugins/axiom/skills/axiom-swiftui-containers-ref/SKILL.md
January 16, 2026
Select agents to install to:
npx add-skill https://github.com/CharlesWiltgen/Axiom/blob/main/.claude-plugin/plugins/axiom/skills/axiom-swiftui-containers-ref/SKILL.md -a claude-code --skill axiom-swiftui-containers-refInstallation paths:
.claude/skills/axiom-swiftui-containers-ref/# SwiftUI Containers Reference
Stacks, grids, outlines, and scroll enhancements. iOS 14 through iOS 26.
**Sources**: WWDC 2020-10031, 2022-10056, 2023-10148, 2024-10144, 2025-256
## Quick Decision
| Use Case | Container | iOS |
|----------|-----------|-----|
| Fixed views vertical/horizontal | VStack / HStack | 13+ |
| Overlapping views | ZStack | 13+ |
| Large scrollable list | LazyVStack / LazyHStack | 14+ |
| Multi-column grid | LazyVGrid | 14+ |
| Multi-row grid (horizontal) | LazyHGrid | 14+ |
| Static grid, precise alignment | Grid | 16+ |
| Hierarchical data (tree) | List with `children:` | 14+ |
| Custom hierarchies | OutlineGroup | 14+ |
| Show/hide content | DisclosureGroup | 14+ |
---
## Part 1: Stacks
### VStack, HStack, ZStack
```swift
VStack(alignment: .leading, spacing: 12) {
Text("Title")
Text("Subtitle")
}
HStack(alignment: .top, spacing: 8) {
Image(systemName: "star")
Text("Rating")
}
ZStack(alignment: .bottomTrailing) {
Image("photo")
Badge()
}
```
**ZStack alignments**: `.center` (default), `.top`, `.bottom`, `.leading`, `.trailing`, `.topLeading`, `.topTrailing`, `.bottomLeading`, `.bottomTrailing`
### Spacer
```swift
HStack {
Text("Left")
Spacer()
Text("Right")
}
Spacer(minLength: 20) // Minimum size
```
---
### LazyVStack, LazyHStack (iOS 14+)
Render children only when visible. Use inside ScrollView.
```swift
ScrollView {
LazyVStack(spacing: 0) {
ForEach(items) { item in
ItemRow(item: item)
}
}
}
```
### Pinned Section Headers
```swift
ScrollView {
LazyVStack(pinnedViews: [.sectionHeaders]) {
ForEach(sections) { section in
Section(header: SectionHeader(section)) {
ForEach(section.items) { item in
ItemRow(item: item)
}
}
}
}
}
```
---
## Part 2: Grids
### Grid (iOS 16+)
Non-lazy grid with precise alignment. Loads all views at once.
```swift
Grid(alig