swiftui-patterns

Implements SwiftUI state management, navigation, and performance patterns for iOS and macOS interfaces.

Updated Mar 18, 2026
One-click install
npx skills add https://github.com/freedom909/real-estate-saas --skill swiftui-patterns-freedom909
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: swiftui-patterns
Source: https://github.com/freedom909/real-estate-saas/tree/main/.trae/skills/swiftui-patterns
Command: npx skills add https://github.com/freedom909/real-estate-saas --skill swiftui-patterns-freedom909

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? SwiftUI developers often struggle with choosing the right property wrappers, structuring navigation, and avoiding unnecessary view re-renders, leading to buggy state handling and sluggish interfaces. ## Core Features & Use Cases - Modern State Management: Guides selection between @State, @Binding, @Observable, @Bindable, and @Environment, replacing legacy ObservableObject patterns. - Type-Safe Navigation: Implements NavigationStack with NavigationPath and enum-based destinations for programmatic routing. - Performance Optimization: Covers lazy containers, stable identifiers, Equatable conformance, and avoiding expensive work in view bodies. - Use Case: When building an item list screen, use this Skill to structure an @Observable view model, inject it via @State, render rows in a LazyVStack, and wire up type-safe navigation to a detail view. ## Quick Start Ask the AI to build a SwiftUI list view with an @Observable view model, searchable text, and NavigationStack routing to a detail screen.

Frequently Asked Questions about swiftui-patterns

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I manage state in SwiftUI with @Observable?▼

Use the @Observable macro on a final class to track property-level changes, then hold it in the view with @State. SwiftUI only re-renders views that read the changed property, replacing the older ObservableObject and @Published pattern.

What is the difference between @State, @Binding, and @Bindable in SwiftUI?▼

@State owns view-local value types, @Binding creates a two-way reference to a parent's @State, and @Bindable creates two-way bindings to properties of an @Observable class. Choose the simplest wrapper that fits the data flow.

How do I implement type-safe navigation with NavigationStack?▼

Create a Hashable enum of destinations and an @Observable Router holding a NavigationPath. Bind the path to NavigationStack and map destinations to views using navigationDestination(for:) for programmatic, type-safe routing.

Should I use @Observable or ObservableObject in new SwiftUI code?▼

Use @Observable in new code because it tracks property-level changes and avoids unnecessary re-renders. ObservableObject, @Published, @StateObject, and @EnvironmentObject are considered legacy patterns to migrate away from.

Why is my SwiftUI List scrolling slowly?▼

Slow scrolling usually comes from eager containers, unstable ForEach identifiers, or expensive modifiers like shadow, blur, and mask triggering offscreen rendering. Use LazyVStack, stable unique IDs, and Equatable conformance on expensive views.

When should I avoid putting async work in a SwiftUI view body?▼

Never perform I/O, network calls, or heavy computation inside body or init. Use the .task modifier for async work since it cancels automatically when the view disappears, or call explicit load methods on the view model.