Communitygithub.com

ComeOnOliver/skillshub

Referenz für SwiftUI-Container – Stacks, Grids, Outlines und Scroll-Erweiterungen bis iOS 26

Was ist skillshub?

Diese Skill-Datei ist eine umfassende Referenz für SwiftUI-Container-Komponenten, die von iOS 14 bis iOS 26 reicht. Sie bietet Entwicklern eine strukturierte Übersicht über die verschiedenen Container-Typen wie VStack, HStack, ZStack, Lazy-Stacks, Grids (Grid, LazyVGrid, LazyHGrid), Outlines (List mit Kindern, OutlineGroup, DisclosureGroup) und Scroll-Erweiterungen (containerRelativeFrame, scrollTargetLayout, scrollPosition, scrollTransition, onScrollGeometryChange, onScrollVisibilityChange). Jeder Abschnitt enthält präzise SwiftUI-Codebeispiele, Entscheidungshilfen für die Containerauswahl, Leistungshinweise (z.B. wann Lazy-Varianten verwendet werden sollten) und spezifische Hinweise zu iOS 26-Performance-Verbesserungen. Die Datei ist als Nachschlagewerk für Entwickler gedacht, die SwiftUI-UI in verschiedenen iOS-Versionen erstellen, und hebt wichtige Änderungen und bewährte Methoden hervor. Sie basiert auf WWDC-Sessions und ergänzenden Skills wie axiom-swiftui-layout und axiom-swiftui-26-ref.

Funktioniert mit~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/ComeOnOliver/skillshub/tree/HEAD/skills/CharlesWiltgen/Axiom/axiom-swiftui-containers-ref

In Ihrer bevorzugten KI fragen

Öffnet einen neuen Chat, in dem dieser Agent-Skill bereits geladen ist.

Dokumentation

SwiftUI Containers Referenz

Stacks, Grids, Outlines und Scroll-Erweiterungen. iOS 14 bis iOS 26.

Quellen: WWDC 2020-10031, 2022-10056, 2023-10148, 2024-10144, 2025-256

Schnellentscheidung

AnwendungsfallContaineriOS
Feste Ansichten vertikal/horizontalVStack / HStack13+
Überlappende AnsichtenZStack13+
Große scrollbare ListeLazyVStack / LazyHStack14+
Mehrspaltiges GridLazyVGrid14+
Mehrzeiliges Grid (horizontal)LazyHGrid14+
Statisches Grid, präzise AusrichtungGrid16+
Hierarchische Daten (Baum)List mit children:14+
Benutzerdefinierte HierarchienOutlineGroup14+
Ein-/Ausblenden von InhaltenDisclosureGroup14+

Teil 1: Stacks

VStack, HStack, ZStack

VStack(alignment: .leading, spacing: 12) {
    Text("Titel")
    Text("Untertitel")
}

HStack(alignment: .top, spacing: 8) {
    Image(systemName: "star")
    Text("Bewertung")
}

ZStack(alignment: .bottomTrailing) {
    Image("foto")
    Badge()
}

ZStack-Ausrichtungen: .center (Standard), .top, .bottom, .leading, .trailing, .topLeading, .topTrailing, .bottomLeading, .bottomTrailing

Spacer

HStack {
    Text("Links")
    Spacer()
    Text("Rechts")
}

Spacer(minLength: 20)  // Mindestgröße

LazyVStack, LazyHStack (iOS 14+)

Rendert Kinder nur, wenn sie sichtbar sind. Innerhalb von ScrollView verwenden.

ScrollView {
    LazyVStack(spacing: 0) {
        ForEach(items) { item in
            ItemRow(item: item)
        }
    }
}

Angeheftete Abschnittsköpfe

ScrollView {
    LazyVStack(pinnedViews: [.sectionHeaders]) {
        ForEach(sections) { section in
            Section(header: SectionHeader(section)) {
                ForEach(section.items) { item in
                    ItemRow(item: item)
                }
            }
        }
    }
}

Teil 2: Grids

Grid (iOS 16+)

Nicht-lazy Grid mit präziser Ausrichtung. Lädt alle Ansichten auf einmal.

Grid(alignment: .leading, horizontalSpacing: 10, verticalSpacing: 10) {
    GridRow {
        Text("Name")
        TextField("Name eingeben", text: $name)
    }
    GridRow {
        Text("E-Mail")
        TextField("E-Mail eingeben", text: $email)
    }
}

Modifikatoren:

  • gridCellColumns(_:) — Über mehrere Spalten spannen
  • gridColumnAlignment(_:) — Spaltenausrichtung überschreiben
Grid {
    GridRow {
        Text("Kopfzeile").gridCellColumns(2)
    }
    GridRow {
        Text("Links")
        Text("Rechts").gridColumnAlignment(.trailing)
    }
}

LazyVGrid (iOS 14+)

Vertikal scrollbares Grid. Definiere Spalten; Zeilen wachsen unbegrenzt.

let columns = [
    GridItem(.flexible()),
    GridItem(.flexible()),
    GridItem(.flexible())
]

ScrollView {
    LazyVGrid(columns: columns, spacing: 16) {
        ForEach(items) { item in
            ItemCard(item: item)
        }
    }
}

LazyHGrid (iOS 14+)

Horizontal scrollbares Grid. Definiere Zeilen; Spalten wachsen unbegrenzt.

let rows = [GridItem(.fixed(100)), GridItem(.fixed(100))]

ScrollView(.horizontal) {
    LazyHGrid(rows: rows, spacing: 16) {
        ForEach(items) { item in
            ItemCard(item: item)
        }
    }
}

GridItem.Size

GrößeVerhalten
.fixed(CGFloat)Exakte Breite/Höhe
.flexible(minimum:maximum:)Füllt Platz gleichmäßig
.adaptive(minimum:maximum:)Erzeugt so viele wie passen
// Adaptiv: responsive Spaltenanzahl
let columns = [GridItem(.adaptive(minimum: 150))]

Teil 3: Outlines

List mit hierarchischen Daten (iOS 14+)

struct FileItem: Identifiable {
    let id = UUID()
    var name: String
    var children: [FileItem]?  // nil = Blatt
}

List(files, children: \.children) { file in
    Label(file.name, systemImage: file.children != nil ? "folder" : "doc")
}
.listStyle(.sidebar)

OutlineGroup (iOS 14+)

Für benutzerdefinierte hierarchische Layouts außerhalb von List.

List {
    ForEach(canvases) { canvas in
        Section(header: Text(canvas.name)) {
            OutlineGroup(canvas.graphics, children: \.children) { graphic in
                GraphicRow(graphic: graphic)
            }
        }
    }
}

DisclosureGroup (iOS 14+)

@State private var isExpanded = false

DisclosureGroup("Erweiterte Optionen", isExpanded: $isExpanded) {
    Toggle("Feature aktivieren", isOn: $feature)
    Slider(value: $intensity)
}

Teil 4: Häufige Muster

Foto-Grid

let columns = [GridItem(.adaptive(minimum: 100), spacing: 2)]

ScrollView {
    LazyVGrid(columns: columns, spacing: 2) {
        ForEach(photos) { photo in
            AsyncImage(url: photo.thumbnailURL) { image in
                image.resizable().aspectRatio(1, contentMode: .fill)
            } placeholder: { Color.gray }
            .aspectRatio(1, contentMode: .fill)
            .clipped()
        }
    }
}

Horizontales Karussell

ScrollView(.horizontal, showsIndicators: false) {
    LazyHStack(spacing: 16) {
        ForEach(items) { item in
            CarouselCard(item: item).frame(width: 280)
        }
    }
    .padding(.horizontal)
}

Dateibrowser

List(selection: $selection) {
    OutlineGroup(rootItems, children: \.children) { item in
        Label {
            Text(item.name)
        } icon: {
            Image(systemName: item.children != nil ? "folder.fill" : "doc.fill")
        }
    }
}
.listStyle(.sidebar)

Teil 5: Leistung

Wann Lazy verwenden

GrößeScrollbar?Verwendung
1-20NeinVStack/HStack
1-20JaVStack/HStack in ScrollView
20-100JaLazyVStack/LazyHStack
100+JaLazyVStack/LazyHStack oder List
Grid <50NeinGrid
Grid 50+JaLazyVGrid/LazyHGrid

GridItem-Arrays cachen — außerhalb von body definieren:

struct ContentView: View {
    let columns = [GridItem(.adaptive(minimum: 150))]  // ✅
    var body: some View {
        LazyVGrid(columns: columns) { ... }
    }
}

iOS 26 Leistung

  • 6x schnellere List-Ladezeiten für 100k+ Elemente
  • 16x schnellere Listenaktualisierungen
  • Reduzierte verpasste Frames beim Scrollen
  • Verschachtelte ScrollViews mit Lazy-Stacks laden jetzt korrekt verzögert:
ScrollView(.horizontal) {
    LazyHStack {
        ForEach(photoSets) { set in
            ScrollView(.vertical) {
                LazyVStack {
                    ForEach(set.photos) { PhotoView(photo: $0) }
                }
            }
        }
    }
}

Teil 6: Scroll-Erweiterungen

containerRelativeFrame (iOS 17+)

Größe von Ansichten relativ zum Scroll-Container.

ScrollView(.horizontal) {
    LazyHStack {
        ForEach(cards) { card in
            CardView(card: card)
                .containerRelativeFrame(.horizontal, count: 3, span: 1, spacing: 16)
        }
    }
}

scrollTargetLayout (iOS 17+)

Einrasten aktivieren.

ScrollView(.horizontal) {
    LazyHStack {
        ForEach(items) { ItemCard(item: $0) }
    }
    .scrollTargetLayout()
}
.scrollTargetBehavior(.viewAligned)

scrollPosition (iOS 17+)

Das oberste sichtbare Element verfolgen. Erfordert .id() auf jedem Element.

@State private var position: Item.ID?

ScrollView {
    LazyVStack {
        ForEach(items) { item in
            ItemRow(item: item).id(item.id)
        }
    }
}
.scrollPosition(id: $position)

scrollTransition (iOS 17+)

.scrollTransition { content, phase in
    content
        .opacity(1 - abs(phase.value) * 0.5)
        .scaleEffect(phase.isIdentity ? 1.0 : 0.75)
}

onScrollGeometryChange (iOS 18+)

.onScrollGeometryChange(for: Bool.self) { geo in
    geo.contentOffset.y < geo.contentInsets.top
} action: { _, isTop in
    showBackButton = !isTop
}

onScrollVisibilityChange (iOS 18+)

VideoPlayer(player: player)
    .onScrollVisibilityChange(threshold: 0.2) { visible in
        visible ? player.play() : player.pause()
    }

Ressourcen

WWDC: 2020-10031, 2022-10056, 2023-10148, 2024-10144, 2025-256

Dokumentation: /swiftui/lazyvstack, /swiftui/lazyvgrid, /swiftui/lazyhgrid, /swiftui/grid, /swiftui/outlinegroup, /swiftui/disclosuregroup

Skills: axiom-swiftui-layout, axiom-swiftui-layout-ref, axiom-swiftui-nav, axiom-swiftui-26-ref

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

ComeOnOliver/skillshub

Create stunning, animation-rich HTML presentations from scratch or by converting PowerPoint files. Use when the user wants to build a presentation, convert a PPT/PPTX to web, or create slides for a talk/pitch. Helps non-designers discover their aesthetic through visual exploration rather than abstract choices.

ComeOnOliver/skillshub

Next.js 16+ 和 Turbopack — 增量打包、文件系统缓存、开发速度,以及何时使用 Turbopack 与 webpack。

ComeOnOliver/skillshub

SwiftUI architecture patterns, state management with @Observable, view composition, navigation, performance optimization, and modern iOS/macOS UI best practices.

ComeOnOliver/skillshub

See, Understand, Act on video and audio. See- ingest from local files, URLs, RTSP/live feeds, or live record desktop; return realtime context and playable stream links. Understand- extract frames, build visual/semantic/temporal indexes, and search moments with timestamps and auto-clips. Act- transcode and normalize (codec, fps, resolution, aspect ratio), perform timeline edits (subtitles, text/image overlays, branding, audio overlays, dubbing, translation), generate media assets (image, audio, video), and create real time alerts for events from live streams or desktop capture.

ComeOnOliver/skillshub

AI-assisted video editing workflows for cutting, structuring, and augmenting real footage. Covers the full pipeline from raw capture through FFmpeg, Remotion, ElevenLabs, fal.ai, and final polish in Descript or CapCut. Use when the user wants to edit video, cut footage, create vlogs, or build video content.

ComeOnOliver/skillshub

Next.js 15 애플리케이션을 위한 프론트엔드 개발 가이드라인. React 19, TypeScript, Shadcn/ui, Tailwind CSS를 사용한 모던 패턴. Server Components, Client Components, App Router, 파일 구조, Shadcn/ui 컴포넌트, 성능 최적화, TypeScript 모범 사례 포함. 컴포넌트, 페이지, 기능 생성, 데이터 페칭, 스타일링, 라우팅, 프론트엔드 코드 작업 시 사용.

ComeOnOliver/skillshub

Provides Tamagui patterns for config v4, compiler optimization, styled context, and cross-platform styling. Must use when working with Tamagui projects (tamagui.config.ts, @tamagui imports).

ComeOnOliver/skillshub

Create distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.

ComeOnOliver/skillshub

Create high-converting, visually distinctive landing pages. Use when building marketing pages, product launches, SaaS homepages, or any single-page conversion-focused website. Guides section-by-section composition with anti-AI-slop principles.

ComeOnOliver/skillshub

Auto-loaded context for Portfolio Buddy 2 development. Use for ANY task involving: React 19 development, TypeScript, portfolio analysis features, metrics calculations, trading strategy comparison, or working with the Portfolio Buddy 2 codebase. Contains tech stack, known issues, and architectural constraints.

ComeOnOliver/skillshub

Next.js development tooling via MCP. Inspect routes, components, build info, and debug Next.js apps. Use when working on Next.js applications, debugging routing, or inspecting app structure. NOT for general React or non-Next.js projects.

ComeOnOliver/skillshub

Implement UI using Shadcn MCP (atoms/theme) and 21st.dev MCP (complex sections). Use when adding buttons, layouts, or generating landing pages.

ComeOnOliver/skillshub

A conceptual skill for building an API client in Next.js that handles JWT tokens

ComeOnOliver/skillshub

Best practices and patterns for Next.js App Router, Server Actions, and Routing in this project.

ComeOnOliver/skillshub

The Design System, Theme, and UX rules for the Physical AI Hub.

ComeOnOliver/skillshub

Comprehensive frontend development skill for building modern, performant web applications using ReactJS, NextJS, TypeScript, Tailwind CSS. Includes component scaffolding, performance optimization, bundle analysis, and UI best practices. Use when developing frontend features, optimizing performance, implementing UI/UX designs, managing state, or reviewing frontend code.

ComeOnOliver/skillshub

This document captures learnings from fixing keyboard navigation issues when floating components (Select, DropdownMenu, Popover) have CSS open/close animations.

ComeOnOliver/skillshub

Build Next.js 16 applications with correct patterns and distinctive design. Use when creating pages, layouts, dynamic routes, upgrading from Next.js 15, or implementing proxy.ts. Covers breaking changes (async params/searchParams, Turbopack, cacheComponents) and frontend aesthetics. NOT when building non-React or backend-only applications.

ComeOnOliver/skillshub

Comprehensive Framer Motion animation library for React. Covers motion components, variants, gestures, page transitions, and scroll animations. Use when adding animations to React/Next.js applications.

ComeOnOliver/skillshub

Build interfaces that resonate, not just render. This skill enforces bold, intentional

Verwandte Skills