Communitygithub.com

ComeOnOliver/skillshub

Referencia completa de contenedores SwiftUI: stacks, cuadrículas, esquemas jerárquicos y mejoras de scroll hasta iOS 26.

¿Qué es skillshub?

Este skill proporciona una referencia completa y actualizada sobre los contenedores de SwiftUI, cubriendo desde iOS 14 hasta iOS 26. Está diseñado para desarrolladores que trabajan con SwiftUI y necesitan recordar rápidamente la sintaxis, los casos de uso y las mejores prácticas para VStack, HStack, ZStack, LazyVStack, LazyHStack, Grid, LazyVGrid, LazyHGrid, OutlineGroup, DisclosureGroup y las mejoras de scroll introducidas en iOS 17 y 18. El skill organiza la información en partes claras: stacks, cuadrículas, esquemas jerárquicos, patrones comunes, rendimiento y mejoras de scroll. Incluye tablas de decisión rápida, ejemplos de código Swift listos para copiar y pegar, y consejos de rendimiento como cuándo usar vistas perezosas y cómo optimizar GridItem. También cubre las nuevas capacidades de iOS 26, incluyendo la carga 6x más rápida de listas grandes. Es un recurso valioso tanto para principiantes como para desarrolladores experimentados que buscan una guía de referencia rápida y precisa.

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

Preguntar en tu IA favorita

Abre un nuevo chat con esta habilidad de agente ya precargada.

Documentación

Referencia de Contenedores SwiftUI

Stacks, cuadrículas, esquemas jerárquicos y mejoras de scroll. iOS 14 hasta iOS 26.

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

Decisión rápida

Caso de usoContenedoriOS
Vistas fijas verticales/horizontalesVStack / HStack13+
Vistas superpuestasZStack13+
Lista grande desplazableLazyVStack / LazyHStack14+
Cuadrícula de varias columnasLazyVGrid14+
Cuadrícula de varias filas (horizontal)LazyHGrid14+
Cuadrícula estática, alineación precisaGrid16+
Datos jerárquicos (árbol)List con children:14+
Jerarquías personalizadasOutlineGroup14+
Mostrar/ocultar contenidoDisclosureGroup14+

Parte 1: Stacks

VStack, HStack, ZStack

VStack(alignment: .leading, spacing: 12) {
    Text("Título")
    Text("Subtítulo")
}

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

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

Alineaciones de ZStack: .center (predeterminado), .top, .bottom, .leading, .trailing, .topLeading, .topTrailing, .bottomLeading, .bottomTrailing

Spacer

HStack {
    Text("Izquierda")
    Spacer()
    Text("Derecha")
}

Spacer(minLength: 20)  // Tamaño mínimo

LazyVStack, LazyHStack (iOS 14+)

Renderiza hijos solo cuando son visibles. Úsalos dentro de ScrollView.

ScrollView {
    LazyVStack(spacing: 0) {
        ForEach(elementos) { elemento in
            FilaElemento(elemento: elemento)
        }
    }
}

Encabezados de sección fijos

ScrollView {
    LazyVStack(pinnedViews: [.sectionHeaders]) {
        ForEach(secciones) { seccion in
            Section(header: EncabezadoSeccion(seccion)) {
                ForEach(seccion.elementos) { elemento in
                    FilaElemento(elemento: elemento)
                }
            }
        }
    }
}

Parte 2: Cuadrículas

Grid (iOS 16+)

Cuadrícula no perezosa con alineación precisa. Carga todas las vistas a la vez.

Grid(alignment: .leading, horizontalSpacing: 10, verticalSpacing: 10) {
    GridRow {
        Text("Nombre")
        TextField("Introduce nombre", text: $nombre)
    }
    GridRow {
        Text("Correo")
        TextField("Introduce correo", text: $correo)
    }
}

Modificadores:

  • gridCellColumns(_:) — Abarcar varias columnas
  • gridColumnAlignment(_:) — Anular alineación de columna
Grid {
    GridRow {
        Text("Encabezado").gridCellColumns(2)
    }
    GridRow {
        Text("Izquierda")
        Text("Derecha").gridColumnAlignment(.trailing)
    }
}

LazyVGrid (iOS 14+)

Cuadrícula de desplazamiento vertical. Define columnas; las filas crecen sin límite.

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

ScrollView {
    LazyVGrid(columns: columnas, spacing: 16) {
        ForEach(elementos) { elemento in
            TarjetaElemento(elemento: elemento)
        }
    }
}

LazyHGrid (iOS 14+)

Cuadrícula de desplazamiento horizontal. Define filas; las columnas crecen sin límite.

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

ScrollView(.horizontal) {
    LazyHGrid(rows: filas, spacing: 16) {
        ForEach(elementos) { elemento in
            TarjetaElemento(elemento: elemento)
        }
    }
}

GridItem.Size

TamañoComportamiento
.fixed(CGFloat)Ancho/alto exacto
.flexible(minimum:maximum:) Rellena el espacio por igual
.adaptive(minimum:maximum:) Crea tantos como quepan
// Adaptativo: número de columnas responsivo
let columnas = [GridItem(.adaptive(minimum: 150))]

Parte 3: Esquemas jerárquicos

List con Datos Jerárquicos (iOS 14+)

struct ElementoArchivo: Identifiable {
    let id = UUID()
    var nombre: String
    var hijos: [ElementoArchivo]?  // nil = hoja
}

List(archivos, children: \.hijos) { archivo in
    Label(archivo.nombre, systemImage: archivo.hijos != nil ? "folder" : "doc")
}
.listStyle(.sidebar)

OutlineGroup (iOS 14+)

Para diseños jerárquicos personalizados fuera de List.

List {
    ForEach(lienzos) { lienzo in
        Section(header: Text(lienzo.nombre)) {
            OutlineGroup(lienzo.graficos, children: \.hijos) { grafico in
                FilaGrafico(grafico: grafico)
            }
        }
    }
}

DisclosureGroup (iOS 14+)

@State private var estaExpandido = false

DisclosureGroup("Opciones avanzadas", isExpanded: $estaExpandido) {
    Toggle("Activar función", isOn: $funcion)
    Slider(value: $intensidad)
}

Parte 4: Patrones comunes

Cuadrícula de fotos

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

ScrollView {
    LazyVGrid(columns: columnas, spacing: 2) {
        ForEach(fotos) { foto in
            AsyncImage(url: foto.urlMiniatura) { imagen in
                imagen.resizable().aspectRatio(1, contentMode: .fill)
            } placeholder: { Color.gray }
            .aspectRatio(1, contentMode: .fill)
            .clipped()
        }
    }
}

Carrusel horizontal

ScrollView(.horizontal, showsIndicators: false) {
    LazyHStack(spacing: 16) {
        ForEach(elementos) { elemento in
            TarjetaCarrusel(elemento: elemento).frame(width: 280)
        }
    }
    .padding(.horizontal)
}

Explorador de archivos

List(selection: $seleccion) {
    OutlineGroup(elementosRaiz, children: \.hijos) { elemento in
        Label {
            Text(elemento.nombre)
        } icon: {
            Image(systemName: elemento.hijos != nil ? "folder.fill" : "doc.fill")
        }
    }
}
.listStyle(.sidebar)

Parte 5: Rendimiento

Cuándo usar Lazy

Tamaño¿Desplazable?Usar
1-20NoVStack/HStack
1-20SíVStack/HStack en ScrollView
20-100SíLazyVStack/LazyHStack
100+SíLazyVStack/LazyHStack o List
Cuadrícula <50NoGrid
Cuadrícula 50+SíLazyVGrid/LazyHGrid

Almacena en caché los arreglos de GridItem — defínelos fuera del cuerpo:

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

Rendimiento iOS 26

  • Carga de listas 6 veces más rápida para 100k+ elementos
  • Actualizaciones de listas 16 veces más rápidas
  • Reducción de fotogramas caídos en desplazamiento
  • ScrollViews anidados con stacks perezosos ahora difieren la carga correctamente:
ScrollView(.horizontal) {
    LazyHStack {
        ForEach(conjuntosFotos) { conjunto in
            ScrollView(.vertical) {
                LazyVStack {
                    ForEach(conjunto.fotos) { VistaFoto(foto: $0) }
                }
            }
        }
    }
}

Parte 6: Mejoras de scroll

containerRelativeFrame (iOS 17+)

Dimensiona las vistas en relación al contenedor de desplazamiento.

ScrollView(.horizontal) {
    LazyHStack {
        ForEach(tarjetas) { tarjeta in
            VistaTarjeta(tarjeta: tarjeta)
                .containerRelativeFrame(.horizontal, count: 3, span: 1, spacing: 16)
        }
    }
}

scrollTargetLayout (iOS 17+)

Habilita el ajuste (snapping).

ScrollView(.horizontal) {
    LazyHStack {
        ForEach(elementos) { TarjetaElemento(elemento: $0) }
    }
    .scrollTargetLayout()
}
.scrollTargetBehavior(.viewAligned)

scrollPosition (iOS 17+)

Rastrea el elemento visible más superior. Requiere .id() en cada elemento.

@State private var posicion: Elemento.ID?

ScrollView {
    LazyVStack {
        ForEach(elementos) { elemento in
            FilaElemento(elemento: elemento).id(elemento.id)
        }
    }
}
.scrollPosition(id: $posicion)

scrollTransition (iOS 17+)

.scrollTransition { contenido, fase in
    contenido
        .opacity(1 - abs(fase.valor) * 0.5)
        .scaleEffect(fase.esIdentidad ? 1.0 : 0.75)
}

onScrollGeometryChange (iOS 18+)

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

onScrollVisibilityChange (iOS 18+)

ReproductorVideo(jugador: jugador)
    .onScrollVisibilityChange(threshold: 0.2) { visible in
        visible ? jugador.play() : jugador.pause()
    }

Recursos

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

Docs: /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

Skills relacionados