guide-swiftui-ui-patterns
Best practices and example-driven guidance for building SwiftUI views and components, including navigation hierarchies, custom view modifiers, and responsive…
Skill by Prisma-Labs-Dev
Install
Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.
npx agentmarket install skill/prisma-labs-dev-guide-swiftui-ui-patterns
Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.
Get the weekly diff
The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.
About
Use cases: design, frontend
Reviews
Write a reviewNo reviews yet. Installed it? Reviews come from verified installers only. How reviews work
Permissions
What this skill can do and what it asks for, from its SKILL.md. Checked Oct 25, 2026.
- Tools
- No tools found
- Secrets
- None asked for
- Install scripts
- None found
Network hosts it talks to 1
codeload.github.com· found in install command
Files it touches
~/.claude/skills/guide-swiftui-ui-patterns
What's inside
- Skill name
guide-swiftui-ui-patterns- Description
- Best practices and example-driven guidance for building SwiftUI views and components, including navigation hierarchies, custom view modifiers, and responsive layouts with stacks and grids. Use when creating or refactoring SwiftUI UI, designing tab architecture with TabView, composing screens with VStack/HStack, managing @State or @Binding, building declarative iOS interfaces, or needing component-specific patterns and examples.
- License
- MIT
- Instructions
- 96 lines in SKILL.md · view on GitHub
Files (38)
- SKILL.md
- accessibility.md · references/
- app-wiring.md · references/
- async-state.md · references/
- components-index.md · references/
- controls.md · references/
- deeplinks.md · references/
- focus.md · references/
- form.md · references/
- grids.md · references/
- haptics.md · references/
- image-optimization.md · references/
- input-toolbar.md · references/
- latest-apis.md · references/
- layout-best-practices.md · references/
- lightweight-clients.md · references/
- list.md · references/
- loading-placeholders.md · references/
- macos-settings.md · references/
- matched-transitions.md · references/
- media.md · references/
- menu-bar.md · references/
- navigationstack.md · references/
- overlay.md · references/
- performance.md · references/
- previews.md · references/
- scroll-patterns.md · references/
- scroll-reveal.md · references/
- scrollview.md · references/
- searchable.md · references/
- sheet-navigation-patterns.md · references/
- sheets.md · references/
- split-views.md · references/
- state-management.md · references/
- tabview.md · references/
- theming.md · references/
- title-menus.md · references/
- top-bar.md · references/
SKILL.md (first lines)
> **Guide Skill** — This is an expert workflow/pattern guide, not API reference documentation.
> Originally from [Dimillian/Skills](https://github.com/Dimillian/Skills) by Thomas Ricouard. MIT License.
# SwiftUI UI Patterns
## Quick start
Choose a track based on your goal:
### Existing project
- Identify the feature or screen and the primary interaction model (list, detail, editor, settings, tabbed).
- Find a nearby example in the repo with `rg "TabView\("` or similar, then read the closest SwiftUI view.
- Apply local conventions: prefer SwiftUI-native state, keep state local when possible, and use environment injection for shared dependencies.
- Choose the relevant component reference from `references/components-index.md` and follow its guidance.
- If the interaction reveals secondary content by dragging or scrolling the primary content away, read `references/scroll-reveal.md` before implementing gestures manually.
- Build the view with small, focused subviews and SwiftUI-native data flow.
### New project scaffolding
- Start with `references/app-wiring.md` to wire TabView + NavigationStack + sheets.
- Add a minimal `AppTab` and `RouterPath` based on the provided skeletons.
- Choose the next component reference based on the UI you need first (TabView, NavigationStack, Sheets).
- Expand the route and sheet enums as new screens are added.
## General rules to follow
- Use modern SwiftUI state (`@State`, `@Binding`, `@Observable`, `@Environment`) and avoid unnecessary view models.
- If the deployment target includes iOS 16 or earlier and cannot use the Observation API introduced in iOS 17, fall back to `ObservableObject` with `@StateObject` for root ownership, `@ObservedObject` for injected observation, and `@EnvironmentObject` only for truly shared app-level state.
- Prefer composition; keep views small and focused.
- Use async/await with `.task` and explicit loading/error states. For restart, cancellation, and debouncing guidance, read `references/async-state.md`.
- Keep shared app services in `@Environment`, but prefer explicit initializer injection for feature-local dependencies and models. For root wiring patterns, read `references/app-wiring.md`.
- Prefer the newest SwiftUI API that fits the deployment target and call out the minimum OS whenever a pattern depends on it.
- Maintain existing legacy patterns only when editing legacy files.
- Follow the project's formatter and style guide.
- **Sheets**: Prefer `.sheet(item:)` over `.sheet(isPresented:)` when state represents a selected model. Avoid `if let` inside a sheet body. Sheets should own their actions and call `dismiss()` internally instead of forwarding `onCancel`/`onConfirm` closures.
- **Scroll-driven reveals**: Prefer deriving a normalized progress value from scroll offset and driving the visual state from that single source of truth. Avoid parallel gesture state machines unless scroll alone cannot express the interaction.
## State ownership summary
Use the narrowest state tool that matches the ownership model:
| Scenario | Preferred pattern |
| --- | --- |
| Local UI state owned by one view | `@State` |
| Child mutates parent-owned value state | `@Binding` |
| Root-owned reference model on iOS 17+ | `@State` with an `@Observable` type |
| Child reads or mutates an injected `@Observable` model on iOS 17+ | Pass it explicitly as a stored property |
| Shared app service or configuration | `@Environment(Type.self)` |
| Legacy reference model on iOS 16 and earlier | `@StateObject` at the root, `@ObservedObject` when injected |
Choose the ownership location first, then pick the wrapper. Do not introduce a reference model when plain value state is enough.
## Cross-cutting references
- `references/navigationstack.md`: navigation ownership, per-tab history, and enum routing.
- `references/sheets.md`: centralized modal presentation and enum-driven sheets.
- `references/deeplinks.md`: URL handling and routing external links into app destinations.
- `references/app-wiring.md`: root dependency graph, environment usage, and app shell wiring.
- `references/async-state.md`: `.task`, `.task(id:)`, cancellation, debouncing, and async UI state.
- `references/previews.md`: `#Preview`, fixtures, mock environments, and isolated preview setup.
- `references/performance.md`: stable identity, observation scope, lazy containers, and render-cost guardrails.
## Anti-patterns
- Giant views that mix layout, business logic, networking, routing, and formatting in one file.
- Multiple boolean flags for mutually exclusive sheets, alerts, or navigation destinations.
- Live service calls directly inside `body`-driven code paths instead of view lifecycle hooks or injected models/services.
- Reaching for `AnyView` to work around type mismatches that should be solved with better composition.
- Defaulting every shared dependency to `@EnvironmentObject` or a global router without a clear ownership reason.
## Workflow for a new SwiftUI view
1. Define the view's state, ownership location, and minimum OS assumptions before writing UI code.
2. Identify which dependencies belong in `@Environment` and which should stay as explicit initializer inputs.
3. Sketch the view hierarchy, routing model, and presentation points; extract repeated parts into subviews. For complex navigation, read `references/navigationstack.md`, `references/sheets.md`, or `references/deeplinks.md`. **Build and verify no compiler errors before proceeding.**
4. Implement async loading with `.task` or `.task(id:)`, plus explicit loading and error states when needed. Read `references/async-state.md` when the work depends on changing inputs or cancellation.
5. Add previews for the primary and secondary states, then add accessibility labels or identifiers when the UI is interactive. Read `references/previews.md` when the view needs fixtures or injected mock dependencies.
6. Validate with a build: confirm no compiler errors, check that previews render without crashing, ensure state changes propagate correctly, and sanity-check that list identity and observation scope will not cause avoidable re-renders. Read `references/performance.md` if the screen is large, scroll-heavy, or frequently updated. For common SwiftUI compilation errors — missing `@State` annotations, ambiguous `ViewBuilder` closures, or mismatched generic types — resolve them before updating callsites. **If the build fails:** read the error message carefully, fix the identified issue, then rebuild before proceeding to the next step. If a preview crashes, isolate the offending subview, confirm its state initialisation is valid, and re-run the preview before continuing.
## Component references
Use `references/components-index.md` as the entry point. Each component reference should include:
- Intent and best-fit scenarios.
- Minimal usage pattern with local conventions.
- Pitfalls and performance notes.
- Paths to existing examples in the current repo.
## Adding a new component reference
- Create `references/<component>.md`.
- Keep it short and actionable; link to concrete files in the current repo.
- Update `references/components-index.md` with the new entry.From Prisma-Labs-Dev/apple-skills, MIT.
More from Prisma-Labs-Dev/apple-skills
- 0.797score
ios-dev
Prisma-Labs-Dev
Start here for any iOS or SwiftUI task.
SkillAFreshness: A★ 349Claude Code +9 - 0.760score
guide-swiftdata
Prisma-Labs-Dev
SwiftData patterns — autosave, relationships, dangerous predicates, CloudKit constraints, indexing, class inheritance.
SkillBFreshness: B★ 349Claude Code +9 - 0.754score
guide-swiftui-animations
Prisma-Labs-Dev
SwiftUI animation patterns — implicit/explicit animations, transitions, phase/keyframe animations, the Animatable protocol, and the @Animatable macro.
SkillBFreshness: B★ 349Claude Code +9 - 0.751score
core-animation
Prisma-Labs-Dev
API reference: Core Animation (QuartzCore).
SkillBFreshness: B★ 349Claude Code +9 - 0.703score
guide-swiftui-view-refactor
Prisma-Labs-Dev
Refactor and review SwiftUI view files with strong defaults for small dedicated subviews, MV-over-MVVM data flow, stable view trees, explicit dependency…
SkillCFreshness: C★ 349Claude Code +9 - 0.697score
apple-docs-index
Prisma-Labs-Dev
Index of Apple developer documentation for iOS, macOS, and related frameworks.
SkillCFreshness: C★ 349Claude Code +9 - 0.697score
ios-ui-craft
Prisma-Labs-Dev
Production-grade SwiftUI with Apple Design Award-quality aesthetics.
SkillCFreshness: C★ 349Claude Code +9 - 0.697score
ios-design-consultant
Prisma-Labs-Dev
UX and visual design consultant for iOS apps using Apple's Liquid Glass design system (iOS 26+).
SkillCFreshness: C★ 349Claude Code +9 - 0.693score
hig
Prisma-Labs-Dev
Fact lookup: Apple Human Interface Guidelines corpus (greppable markdown).
SkillCFreshness: C★ 349Claude Code +9 - 0.693score
uikit
Prisma-Labs-Dev
API reference: UIKit.
SkillCFreshness: C★ 349Claude Code +9 - 0.693score
ios-liquid-glass
Prisma-Labs-Dev
API reference: Liquid Glass (iOS 26+).
SkillCFreshness: C★ 349Claude Code +9 - 0.693score
swiftui
Prisma-Labs-Dev
API reference: SwiftUI.
SkillCFreshness: C★ 349Claude Code +9
Compare and alternatives
Featured in
Signals
- Stars
- 349
- Forks
- 21
- Open issues
- 1
- Last commit (this folder)
- Sep 10, 2026 (1 month ago)
From GitHub (fetched Oct 24, 2026).
Details
- License
- MIT
- Repository
- github.com/Prisma-Labs-Dev/apple-skills
- First seen
- Oct 24, 2026
- Last checked
- Oct 24, 2026
- Source
- GitHubgithub-graphql
More from Prisma-Labs-Dev
- 0.797score
ios-dev
Prisma-Labs-Dev
Start here for any iOS or SwiftUI task.
SkillAFreshness: A★ 349Claude Code +9 - 0.760score
guide-swiftdata
Prisma-Labs-Dev
SwiftData patterns — autosave, relationships, dangerous predicates, CloudKit constraints, indexing, class inheritance.
SkillBFreshness: B★ 349Claude Code +9 - 0.754score
guide-swiftui-animations
Prisma-Labs-Dev
SwiftUI animation patterns — implicit/explicit animations, transitions, phase/keyframe animations, the Animatable protocol, and the @Animatable macro.
SkillBFreshness: B★ 349Claude Code +9 - 0.751score
core-animation
Prisma-Labs-Dev
API reference: Core Animation (QuartzCore).
SkillBFreshness: B★ 349Claude Code +9 - 0.703score
guide-swiftui-view-refactor
Prisma-Labs-Dev
Refactor and review SwiftUI view files with strong defaults for small dedicated subviews, MV-over-MVVM data flow, stable view trees, explicit dependency…
SkillCFreshness: C★ 349Claude Code +9 - 0.697score
apple-docs-index
Prisma-Labs-Dev
Index of Apple developer documentation for iOS, macOS, and related frameworks.
SkillCFreshness: C★ 349Claude Code +9
Cite this page
guide-swiftui-ui-patterns skill. Agent Mart. https://agentmart.dev/skills/prisma-labs-dev-guide-swiftui-ui-patterns (last updated 2026-10-24)