
Swiftui Layout Components
Ship polished SwiftUI screens with stacks, lazy grids, lists, forms, search, and overlays on iOS without reinventing layout patterns.
Install
npx skills add https://github.com/dpearson2699/swift-ios-skills --skill swiftui-layout-componentsWhat is this skill?
- Covers VStack/HStack/ZStack plus LazyVGrid/LazyHGrid for data-heavy scrolling UI
- List sections, swipe actions, ScrollView with ScrollPosition, and Form validation patterns
- Toggle, Picker, Slider, .searchable, and overlay/presentation patterns for settings and search flows
- Targets iOS 26+ / Swift 6.3 with backward-compatible notes to iOS 17
- Includes common-mistakes section and a review checklist before shipping layouts
Adoption & trust: 1.8k installs on skills.sh; 713 GitHub stars; 3/3 security scanners passed (skills.sh audits).
Recommended Skills
Vercel React Native Skillsvercel-labs/agent-skills
Firebase Basicsfirebase/agent-skills
Building Native Uiexpo/skills
Firebase Ai Logic Basicsfirebase/agent-skills
Native Data Fetchingexpo/skills
Firebase Firestorefirebase/agent-skills
Journey fit
Common Questions / FAQ
Is Swiftui Layout Components safe to install?
skills.sh reports 3 of 3 security scanners passed. Review the Security Audits panel on this page before installing in production.
SKILL.md
READMESKILL.md - Swiftui Layout Components
# SwiftUI Layout & Components Layout and component patterns for SwiftUI apps targeting iOS 26+ with Swift 6.3. Covers stack and grid layouts, list patterns, scroll views, forms, controls, search, and overlays. Patterns are backward-compatible to iOS 17 unless noted. ## Contents - [Layout Fundamentals](#layout-fundamentals) - [Grid Layouts](#grid-layouts) - [List Patterns](#list-patterns) - [ScrollView](#scrollview) - [Form and Controls](#form-and-controls) - [Searchable](#searchable) - [Overlay and Presentation](#overlay-and-presentation) - [Common Mistakes](#common-mistakes) - [Review Checklist](#review-checklist) - [References](#references) ## Layout Fundamentals ### Standard Stacks Use `VStack`, `HStack`, and `ZStack` for small, fixed-size content. They render all children immediately. ```swift VStack(alignment: .leading) { Text(title).font(.headline) Text(subtitle).font(.subheadline).foregroundStyle(.secondary) } ``` ### Lazy Stacks Use `LazyVStack` and `LazyHStack` inside `ScrollView` for large or dynamic collections. They create child views on demand as they scroll into view. ```swift ScrollView { LazyVStack { ForEach(items) { item in ItemRow(item: item) } } .padding(.horizontal) } ``` **When to use which:** - **Non-lazy stacks:** Small, fixed content (headers, toolbars, forms with few fields) - **Lazy stacks:** Large or unknown-size collections, feeds, chat messages ## Grid Layouts Use `LazyVGrid` for icon pickers, media galleries, and dense visual selections. Use `.adaptive` columns for layouts that scale across device sizes, or `.flexible` columns for a fixed column count. ```swift // Adaptive grid -- columns adjust to fit let columns = [GridItem(.adaptive(minimum: 120, maximum: 1024))] LazyVGrid(columns: columns) { ForEach(items) { item in ThumbnailView(item: item) .aspectRatio(1, contentMode: .fit) } } ``` ```swift // Fixed 3-column grid let columns = Array(repeating: GridItem(.flexible(minimum: 100), spacing: 4), count: 3) LazyVGrid(columns: columns, spacing: 4) { ForEach(items) { item in ThumbnailView(item: item) } } ``` Use `.aspectRatio` for cell sizing. Never place `GeometryReader` inside lazy containers -- it forces eager measurement and defeats lazy loading. Use `.onGeometryChange` (iOS 16+) if you need to read dimensions. See [references/grids.md](references/grids.md) for full grid patterns and design choices. ## List Patterns Use `List` for feed-style content and settings rows where built-in row reuse, selection, and accessibility matter. ```swift List { Section("General") { NavigationLink("Display") { DisplaySettingsView() } NavigationLink("Haptics") { HapticsSettingsView() } } Section("Account") { Button("Sign Out", role: .destructive) { } } } .listStyle(.insetGrouped) ``` **Key patterns:** - `.listStyle(.plain)` for feed layouts, `.insetGrouped` for settings - `.scrollContentBackground(.hidden)` + custom background for themed surfaces - `.listRowInsets(...)` and `.listRowSeparator(.hidden)` for spacing and separator control - Use `ScrollPosition` with `.scrollPosition($scrollPosition)` for scroll-to-top or jump-to-id - Use `.refreshable { }` for pull-to-refresh feeds - Use `.contentShape(Rectangle())` on rows that should be tappable end-to-end **iOS 26:** Apply `.scrollEdgeEffectStyle(.soft, for: .top)` for modern scroll edge effects. See [references/list.md](references/list.md) for full list pattern