swiftui-ui-patterns

Implements SwiftUI views using navigation, state, and layout patterns with component references.

Updated Mar 12, 2026
One-click install
npx skills add https://github.com/RavitejaKarra24/dotfiles --skill swiftui-ui-patterns-ravitejakarra24
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: swiftui-ui-patterns
Source: https://github.com/RavitejaKarra24/dotfiles/tree/main/agents/.agents/skills/swiftui-ui-patterns
Command: npx skills add https://github.com/RavitejaKarra24/dotfiles --skill swiftui-ui-patterns-ravitejakarra24

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Building SwiftUI interfaces often leads to giant views, tangled state ownership, inconsistent navigation, and ad-hoc sheet handling. This Skill provides opinionated, example-driven patterns for structuring SwiftUI views, navigation hierarchies, state management, and async data loading so screens stay small, testable, and consistent. ## Core Features & Use Cases - Navigation and presentation architecture: Per-tab NavigationStack routers, enum-driven sheet routing, and deep link handling with a single source of truth. - State ownership guidance: Decision tables for choosing @State, @Binding, @Observable, @Environment, or legacy ObservableObject based on ownership and deployment target. - Component reference library: Over 20 focused references covering TabView, List, Form, grids, search, media, haptics, theming, previews, performance, and scroll-reveal interactions. - Use Case: When adding a new settings screen to an iOS app, follow the Form and controls references to build a grouped, themed form with validation, focus chaining, and previews for loading and error states. ## Quick Start Use the swiftui-ui-patterns skill to design a tab-based SwiftUI screen with per-tab NavigationStack routing and enum-driven sheets.

Frequently Asked Questions about swiftui-ui-patterns

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

FAQPage Schema
How do I structure navigation in a SwiftUI app with multiple tabs?

Use one NavigationStack per tab, each bound to its own router object holding a path array of Hashable route enums. Inject the router into the environment so child views navigate programmatically, and centralize destination mapping with a single navigationDestination modifier.

When should I use @State vs @Observable vs @EnvironmentObject in SwiftUI?

Use @State for local value state owned by one view, @State with an @Observable type for root-owned reference models on iOS 17+, and @Environment for shared app services. Reserve @StateObject and @ObservedObject for iOS 16 and earlier, and @EnvironmentObject only for truly shared app-level state.

How do I present sheets in SwiftUI without prop drilling?

Define an Identifiable SheetDestination enum, store the current sheet on a router object, and map destinations to views with a sheet(item:) modifier. Child views set router.presentedSheet directly, and sheets own their actions by calling dismiss() internally.

Does this SwiftUI guidance support iOS 16 deployment targets?

Yes, the patterns call out minimum OS requirements and provide fallbacks. When the Observation API from iOS 17 is unavailable, use ObservableObject with @StateObject at the root and @ObservedObject for injected models.

Why does my SwiftUI list stutter when scrolling?

Janky scrolling usually comes from unstable ForEach identity, expensive work inside body, or overly broad observation scope. Give rows stable IDs, move sorting and formatting out of body, and use lazy containers like List or LazyVStack for large collections.

How do I debounce search requests in SwiftUI?

Bind searchable(text:) to local state and use .task(id: query) so the task restarts on each change. Sleep briefly inside the task, check Task.isCancelled, and skip empty queries to avoid firing a network request per keystroke.