Communitygithub.com

ComeOnOliver/skillshub

Référence — Stacks, grilles, plans et améliorations de défilement SwiftUI jusqu'à iOS 26.

Qu'est-ce que skillshub ?

Cette compétence sert de référence complète pour les conteneurs de mise en page SwiftUI, couvrant les stacks, les grilles, les plans hiérarchiques et les améliorations de défilement de iOS 14 à iOS 26. Elle aide les développeurs à choisir rapidement le bon conteneur selon leur cas d'usage, avec des tableaux de décision et des extraits de code prêts à l'emploi. La compétence couvre les éléments essentiels comme VStack/HStack/ZStack, les conteneurs paresseux (LazyVStack, LazyHStack, LazyVGrid, LazyHGrid), Grid (iOS 16+), OutlineGroup, DisclosureGroup, ainsi que les nouveautés des versions récentes comme containerRelativeFrame, scrollTargetLayout, scrollPosition, scrollTransition (iOS 17+), et onScrollGeometryChange et onScrollVisibilityChange (iOS 18+). Elle inclut également des conseils de performance pour choisir entre conteneurs paresseux et non paresseux, avec des améliorations spécifiques pour iOS 26 telles que le chargement 6 fois plus rapide des listes et la gestion optimisée des ScrollViews imbriqués.

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

Demander à votre IA préférée

Ouvre une nouvelle conversation avec cette compétence d'agent déjà préchargée.

Documentation

Référence des conteneurs SwiftUI

Stacks, grilles, plans et améliorations de défilement. iOS 14 à iOS 26.

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

Décision rapide

Cas d'utilisationConteneuriOS
Vues fixes verticales/horizontalesVStack / HStack13+
Vues superposéesZStack13+
Grande liste défilanteLazyVStack / LazyHStack14+
Grille multi-colonnesLazyVGrid14+
Grille multi-lignes (horizontale)LazyHGrid14+
Grille statique, alignement précisGrid16+
Données hiérarchiques (arbre)List avec children:14+
Hiérarchies personnaliséesOutlineGroup14+
Afficher/masquer du contenuDisclosureGroup14+

Partie 1 : Stacks

VStack, HStack, ZStack

VStack(alignment: .leading, spacing: 12) {
    Text("Titre")
    Text("Sous-titre")
}

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

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

Alignements ZStack : .center (défaut), .top, .bottom, .leading, .trailing, .topLeading, .topTrailing, .bottomLeading, .bottomTrailing

Spacer

HStack {
    Text("Gauche")
    Spacer()
    Text("Droite")
}

Spacer(minLength: 20)  // Taille minimale

LazyVStack, LazyHStack (iOS 14+)

Rendent les enfants uniquement lorsqu'ils sont visibles. Utilisation à l'intérieur d'un ScrollView.

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

En-têtes de section épinglés

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

Partie 2 : Grilles

Grid (iOS 16+)

Grille non paresseuse avec alignement précis. Charge toutes les vues à la fois.

Grid(alignment: .leading, horizontalSpacing: 10, verticalSpacing: 10) {
    GridRow {
        Text("Nom")
        TextField("Saisir le nom", text: $name)
    }
    GridRow {
        Text("Email")
        TextField("Saisir l'email", text: $email)
    }
}

Modificateurs :

  • gridCellColumns(_:) — Étend sur plusieurs colonnes
  • gridColumnAlignment(_:) — Remplace l'alignement de colonne
Grid {
    GridRow {
        Text("En-tête").gridCellColumns(2)
    }
    GridRow {
        Text("Gauche")
        Text("Droite").gridColumnAlignment(.trailing)
    }
}

LazyVGrid (iOS 14+)

Grille à défilement vertical. Définit les colonnes ; les lignes croissent sans limite.

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

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

LazyHGrid (iOS 14+)

Grille à défilement horizontal. Définit les lignes ; les colonnes croissent sans limite.

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

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

GridItem.Size

TailleComportement
.fixed(CGFloat)Largeur/hauteur exacte
.flexible(minimum:maximum:)Remplit l'espace équitablement
.adaptive(minimum:maximum:)Crée autant d'éléments que possible
// Adaptatif : nombre de colonnes réactif
let columns = [GridItem(.adaptive(minimum: 150))]

Partie 3 : Plans

List avec données hiérarchiques (iOS 14+)

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

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

OutlineGroup (iOS 14+)

Pour des mises en page hiérarchiques personnalisées en dehors de 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("Options avancées", isExpanded: $isExpanded) {
    Toggle("Activer la fonctionnalité", isOn: $feature)
    Slider(value: $intensity)
}

Partie 4 : Modèles courants

Grille de photos

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()
        }
    }
}

Carrousel horizontal

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

Navigateur de fichiers

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)

Partie 5 : Performances

Quand utiliser Lazy

TailleDéfilable ?Utilisation
1-20NonVStack/HStack
1-20OuiVStack/HStack dans ScrollView
20-100OuiLazyVStack/LazyHStack
100+OuiLazyVStack/LazyHStack ou List
Grille <50NonGrid
Grille 50+OuiLazyVGrid/LazyHGrid

Mettre en cache les tableaux GridItem — définir en dehors du body :

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

Performances iOS 26

  • Chargement de liste 6x plus rapide pour 100k+ éléments
  • Mises à jour de liste 16x plus rapides
  • Réduction des images sautées lors du défilement
  • ScrollViews imbriqués avec stacks paresseux diffèrent désormais correctement le chargement :
ScrollView(.horizontal) {
    LazyHStack {
        ForEach(photoSets) { set in
            ScrollView(.vertical) {
                LazyVStack {
                    ForEach(set.photos) { PhotoView(photo: $0) }
                }
            }
        }
    }
}

Partie 6 : Améliorations du défilement

containerRelativeFrame (iOS 17+)

Dimensionne les vues par rapport au conteneur de défilement.

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

scrollTargetLayout (iOS 17+)

Active l'accrochage.

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

scrollPosition (iOS 17+)

Suivre l'élément visible le plus en haut. Nécessite .id() sur chaque élément.

@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()
    }

Ressources

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

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

Compétences : 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

Skills associés