Communitygithub.com

SwiftUI UI パターン

SwiftUI ビューとコンポーネントを構築するためのベストプラクティスと実例に基づくガイドです。SwiftUI の UI を作成またはリファクタリングするとき、TabView でタブアーキテクチャを設計するとき、画面を構成するとき、またはコンポーネント固有のパターンや例が必要なときに使用します。

SwiftUI UI パターン とは?

このスキルは、SwiftUI を使用した UI 開発におけるベストプラクティスと具体的な実装パターンを提供します。開発者は、既存のプロジェクトに新しい機能を追加する場合や、新しいプロジェクトをゼロからスキャフォールディングする場合に、目的に応じたワークフローを選択できます。SwiftUI ネイティブの状態管理(@State、@Binding、@Observable、@Environment)を推奨し、不要な ViewModel を避け、コンポジションによる小さなビューの再利用を促進します。特にシート表示では `.sheet(item:)` の使用とシート内でのアクション完結型の設計を推奨し、dismiss() を内部で呼び出すパターンを採用します。さらに、コンポーネントリファレンスのインデックス(references/components-index.md)をエントリポイントとして、各コンポーネントの意図、最適なシナリオ、使用パターン、パフォーマンス上の注意点、既存のコード例へのパスを提供します。新しいコンポーネントを追加する場合は、短く実用的なリファレンスを作成し、インデックスを更新する手順も含まれています。

対応~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/ulasalyesil/personal-website-v2/tree/HEAD/.agent/skills/swiftui-ui-patterns

お気に入りのAIに質問する

このエージェントスキルを事前に読み込んだ状態で新しいチャットを開きます。

ドキュメント

SwiftUI UI パターン は何をしますか?

クイックスタート

目標に基づいてトラックを選択してください。

既存のプロジェクト

  • フィーチャーまたは画面と、その主要なインタラクションモデル(リスト、詳細、エディタ、設定、タブ)を特定します。
  • rg "TabView\(" などを使用してリポジトリ内の近くの例を見つけ、最も近い SwiftUI ビューを読みます。
  • ローカルな規約を適用する: SwiftUI ネイティブの状態を優先し、可能な限り状態をローカルに保ち、共有依存関係には環境インジェクションを使用します。
  • references/components-index.md から関連するコンポーネントリファレンスを選択し、そのガイダンスに従います。
  • 小さく焦点を絞ったサブビューと SwiftUI ネイティブのデータフローを使用してビューを構築します。

新規プロジェクトのスキャフォールディング

  • references/app-scaffolding-wiring.md から始めて、TabView + NavigationStack + sheets を配線します。
  • 提供されたスケルトンに基づいて、最小限の AppTab と RouterPath を追加します。
  • 最初に必要な UI に基づいて、次のコンポーネントリファレンスを選択します(TabView、NavigationStack、Sheets)。
  • 新しい画面が追加されるにつれて、ルートとシートの enum を拡張します。

従うべき一般ルール

  • 最新の SwiftUI 状態(@State、@Binding、@Observable、@Environment)を使用し、不要な ViewModel を避けます。
  • コンポジションを優先し、ビューを小さく焦点を絞ったものに保ちます。
  • .task と明示的な読み込み/エラー状態を伴う async/await を使用します。
  • 既存のレガシーファイルを編集する場合のみ、既存のレガシーパターンを維持します。
  • プロジェクトのフォーマッターとスタイルガイドに従います。
  • シート: 状態が選択されたモデルを表す場合は、.sheet(isPresented:) よりも .sheet(item:) を優先します。シート本体内での if let の使用は避けてください。シートは自身のアクションを所有し、onCancel/onConfirm クロージャを転送する代わりに、内部で dismiss() を呼び出す必要があります。

新しい SwiftUI ビューのワークフロー

  1. ビューの状態とその所有権の場所を定義します。
  2. @Environment を介して注入する依存関係を特定します。
  3. ビュー階層をスケッチし、繰り返し部分をサブビューに抽出します。
  4. .task と必要に応じて明示的な状態 enum を使用して非同期読み込みを実装します。
  5. UI がインタラクティブな場合、アクセシビリティラベルまたは識別子を追加します。
  6. ビルドで検証し、必要に応じて使用箇所を更新します。

コンポーネントリファレンス

エントリポイントとして references/components-index.md を使用します。各コンポーネントリファレンスには以下を含める必要があります:

  • 意図と最適なシナリオ。
  • ローカルな規約に沿った最小限の使用パターン。
  • 落とし穴とパフォーマンスに関する注意点。
  • 現在のリポジトリ内の既存の例へのパス。

シートパターン

アイテム駆動シート(推奨)

@State private var selectedItem: Item?

.sheet(item: $selectedItem) { item in
    EditItemSheet(item: item)
}

シートがアクションを所有する

struct EditItemSheet: View {
    @Environment(\.dismiss) private var dismiss
    @Environment(Store.self) private var store

    let item: Item
    @State private var isSaving = false

    var body: some View {
        VStack {
            Button(isSaving ? "保存中…" : "保存") {
                Task { await save() }
            }
        }
    }

    private func save() async {
        isSaving = true
        await store.save(item)
        dismiss()
    }
}

新しいコンポーネントリファレンスの追加

  • references/<component>.md を作成します。
  • 短く実用的に保ち、現在のリポジトリ内の具体的なファイルにリンクします。
  • references/components-index.md を新しいエントリで更新します。

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

ulasalyesil/personal-website-v2

Create beautiful visual art in .png and .pdf documents using design philosophy. You should use this skill when the user asks to create a poster, piece of art, design, or other static piece. Create original visual designs, never copying existing artists' work to avoid copyright violations.

ulasalyesil/personal-website-v2

Conduct design interviews, generate five distinct UI variations in a temporary design lab, collect feedback, and produce implementation plans. Use when the user wants to explore UI design options, redesign existing components, or create new UI with multiple approaches to compare.

ulasalyesil/personal-website-v2

Create distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, artifacts, posters, or applications (examples include websites, landing pages, dashboards, React components, HTML/CSS layouts, or when styling/beautifying any web UI). Generates creative, polished code and UI design that avoids generic AI aesthetics.

ulasalyesil/personal-website-v2

Design and implement microinteractions, motion design, transitions, and user feedback patterns. Use when adding polish to UI interactions, implementing loading states, or creating delightful user experiences.

ulasalyesil/personal-website-v2

This skill is for interface design — dashboards, admin panels, apps, tools, and interactive products. NOT for marketing design (landing pages, marketing sites, campaigns).

ulasalyesil/personal-website-v2

UI/UX design intelligence. 50 styles, 21 palettes, 50 font pairings, 20 charts, 9 stacks (React, Next.js, Vue, Svelte, SwiftUI, React Native, Flutter, Tailwind, shadcn/ui). Actions: plan, build, create, design, implement, review, fix, improve, optimize, enhance, refactor, check UI/UX code. Projects: website, landing page, dashboard, admin panel, e-commerce, SaaS, portfolio, blog, mobile app, .html, .tsx, .vue, .svelte. Elements: button, modal, navbar, sidebar, card, table, form, chart. Styles: glassmorphism, claymorphism, minimalism, brutalism, neumorphism, bento grid, dark mode, responsive, skeuomorphism, flat design. Topics: color palette, accessibility, animation, layout, typography, font pairing, spacing, hover, shadow, gradient. Integrations: shadcn/ui MCP for component search and examples.

ulasalyesil/personal-website-v2

Conduct WCAG 2.2 accessibility audits with automated testing, manual verification, and remediation guidance. Use when auditing websites for accessibility, fixing WCAG violations, or implementing accessible design patterns.

ulasalyesil/personal-website-v2

Review UI code for Web Interface Guidelines compliance. Use when asked to "review my UI", "check accessibility", "audit design", "review UX", or "check my site against best practices".

ulasalyesil/personal-website-v2

Enforces an opinionated UI baseline to prevent AI-generated interface slop.

ulasalyesil/personal-website-v2

Build modern, composable, and accessible React UI components following the components.build specification. Use when creating, reviewing, or refactoring component libraries, design systems, or any reusable UI components. Triggers on tasks involving component APIs, composition patterns, accessibility, styling systems, or TypeScript props.

ulasalyesil/personal-website-v2

Ship correct, complete metadata.

ulasalyesil/personal-website-v2

Survey any codebase as a senior advisor and produce prioritized, self-contained implementation plans for OTHER models/agents to execute. Strictly read-only on source code — never implements, fixes, or refactors anything itself. Use when asked to audit a codebase, find improvement opportunities (bugs, security, performance, test coverage, tech debt, migrations, DX), suggest features or where to take the project next (roadmap, product direction), or generate handoff plans for another agent to implement.

ulasalyesil/personal-website-v2

Defines the product's objects, relationships, states, and vocabulary independently of any interface — the most load-bearing layer

ulasalyesil/personal-website-v2

Maps domain concepts, terminology conflicts, and bounded contexts — produces a noun harvest for the conceptual model layer

ulasalyesil/personal-website-v2

Maps interaction structure and flow — produces breadboard notation with edge cases, failure paths, and open decisions

ulasalyesil/personal-website-v2

Framework orientation for Layers of Product Design — load this first; provides the context all other skills depend on

ulasalyesil/personal-website-v2

User research planning and synthesis at the observed behaviour layer — produces candidate job stories with confidence ratings

ulasalyesil/personal-website-v2

Diagnostic audit across all seven layers — identifies the bottleneck layer and recommends where to focus

ulasalyesil/personal-website-v2

Connects user opportunities to business outcomes and solution bets — produces a strategy tree and prioritised experiments

ulasalyesil/personal-website-v2

Audits existing surface against lower-layer decisions and produces a surface decision inventory — vocabulary, object consistency, completeness, feedback, hierarchy, accessibility

関連スキル