本文へ移動
cccskills
無料GitHub で公開

toolbars

Modern SwiftUI toolbar patterns including customizable toolbars, search integration, transition effects, and platform-specific behavior. Use when implementing or customizing toolbars in SwiftUI.

インストール方法を見る

含まれるファイル(1)

  • SKILL.md8.6 KB

SKILL.md(原文)

インストールする前に、エージェントに与えられる指示の中身を確認できます。

SwiftUI Toolbars

Modern toolbar patterns for SwiftUI apps. Covers customizable toolbars, enhanced search integration, new placements, transition effects, and platform-specific considerations.

When This Skill Activates

Use this skill when the user:

  • Wants to add or customize toolbars
  • Asks about customizable/user-configurable toolbars
  • Needs search field in toolbar with specific placement
  • Wants toolbar item transitions or animations
  • Asks about toolbar placements (bottomBar, largeSubtitle, etc.)
  • Needs platform-specific toolbar behavior (iOS vs macOS)
  • Wants to reposition system toolbar items (search, sidebar)

Decision Tree

What toolbar feature do you need?
|
+- User-customizable toolbar (add/remove/reorder items)
|  +- Use .toolbar(id:) with ToolbarItem(id:)
|
+- Search field in toolbar
|  +- Minimize to button -> .searchToolbarBehavior(.minimize)
|  +- Reposition search -> DefaultToolbarItem(kind: .search, placement:)
|
+- Toolbar transition/animation
|  +- Zoom transition from toolbar item -> .matchedTransitionSource(id:in:)
|  +- Hide glass background -> .sharedBackgroundVisibility(.hidden)
|
+- Custom subtitle area content
|  +- Use ToolbarItem(placement: .largeSubtitle)
|
+- System toolbar items with custom placement
|  +- DefaultToolbarItem(kind: .search/.sidebar, placement:)

API Availability

APIMinimum VersionNotes
.toolbar { }iOS 14Basic toolbar
ToolbarItem(placement:)iOS 14Standard placements
.toolbar(id:)iOS 16Customizable toolbars
ToolbarItem(id:)iOS 16Items in customizable toolbars
ToolbarSpaceriOS 16Fixed and flexible spacers
.searchable()iOS 15Search integration
.searchToolbarBehavior(.minimize)iOS 17Minimized search button
DefaultToolbarItem(kind:placement:)iOS 18Reposition system items
ToolbarItem(placement: .largeSubtitle)iOS 18Subtitle area content
.matchedTransitionSource(id:in:)iOS 18Toolbar transition source
.sharedBackgroundVisibility()iOS 18Glass background control

Customizable Toolbars

Allow users to personalize toolbar items by adding, removing, and rearranging:

ContentView()
    .toolbar(id: "main-toolbar") {
        ToolbarItem(id: "tag") {
            TagButton()
        }
        ToolbarItem(id: "share") {
            ShareButton()
        }
        ToolbarSpacer(.fixed)
        ToolbarItem(id: "more") {
            MoreButton()
        }
    }

Toolbar Spacers

ToolbarSpacer(.fixed)      // Fixed-width space
ToolbarSpacer(.flexible)   // Flexible space — pushes items apart

Anti-Patterns

// ❌ Missing IDs in customizable toolbar — items can't be customized
.toolbar(id: "main") {
    ToolbarItem {           // No id parameter
        ShareButton()
    }
}

// ✅ Every item needs its own ID
.toolbar(id: "main") {
    ToolbarItem(id: "share") {
        ShareButton()
    }
}

Enhanced Search Integration

Minimized Search

Renders search field as a compact button that expands on tap:

@State private var searchText = ""

NavigationStack {
    RecipeList()
        .searchable(text: $searchText)
        .searchToolbarBehavior(.minimize)
}

Repositioning Search

Move the default search field to a different toolbar position:

NavigationSplitView {
    AllCalendarsView()
} detail: {
    SelectedCalendarView()
        .searchable(text: $query)
        .toolbar {
            ToolbarItem(placement: .bottomBar) {
                CalendarPicker()
            }
            ToolbarItem(placement: .bottomBar) {
                Invites()
            }
            DefaultToolbarItem(kind: .search, placement: .bottomBar)
            ToolbarSpacer(placement: .bottomBar)
            ToolbarItem(placement: .bottomBar) {
                NewEventButton()
            }
        }
}

System-Defined Toolbar Items

Reposition system items with custom placements:

.toolbar {
    DefaultToolbarItem(kind: .search, placement: .bottomBar)
    DefaultToolbarItem(kind: .sidebar, placement: .navigationBarLeading)
}

Large Subtitle Placement

Place custom content in the navigation bar subtitle area:

NavigationStack {
    DetailView()
        .navigationTitle("Title")
        .navigationSubtitle("Subtitle")
        .toolbar {
            ToolbarItem(placement: .largeSubtitle) {
                CustomLargeNavigationSubtitle()
            }
        }
}

Transition Effects

Matched Transition from Toolbar

Create zoom transitions originating from a toolbar button:

struct ContentView: View {
    @State private var isPresented = false
    @Namespace private var namespace

    var body: some View {
        NavigationStack {
            DetailView()
                .toolbar {
                    ToolbarItem(placement: .topBarTrailing) {
                        Button("Show Sheet", systemImage: "globe") {
                            isPresented = true
                        }
                    }
                    .matchedTransitionSource(id: "world", in: namespace)
                }
                .sheet(isPresented: $isPresented) {
                    SheetView()
                        .navigationTransition(
                            .zoom(sourceID: "world", in: namespace))
                }
        }
    }
}

Glass Background Control

Control the shared glass background on toolbar items:

ContentView()
    .toolbar(id: "main") {
        ToolbarItem(id: "build-status", placement: .principal) {
            BuildStatus()
        }
        .sharedBackgroundVisibility(.hidden)
    }

Top 5 Mistakes

#MistakeFix
1Missing id on ToolbarItem in customizable toolbarEvery item in .toolbar(id:) must have its own id parameter
2Using .searchToolbarBehavior(.minimize) without .searchable()Must pair with .searchable() modifier — .minimize only affects rendering
3Putting .matchedTransitionSource on the Button instead of ToolbarItemApply .matchedTransitionSource(id:in:) on the ToolbarItem, not its content
4Using .largeSubtitle alongside .navigationSubtitle() expecting both to show.largeSubtitle takes precedence — the subtitle modifier value is hidden
5Forgetting placement: on DefaultToolbarItemWithout explicit placement, system items use their default position

Platform Considerations

PlatformRecommendations
iOSBottom bar useful on iPhones. Use .searchToolbarBehavior(.minimize) for space efficiency.
iPadOSCustomizable toolbars valuable in productivity apps. Consider keyboard shortcuts.
macOSUsers expect toolbar customization. Use spacers for logical groupings.

Review Checklist

Customizable Toolbars

  • .toolbar(id:) has a unique, stable string identifier
  • Every ToolbarItem within has its own unique id
  • Spacers used to create logical groups of related items
  • Toolbar tested with customization panel (long-press on iPadOS, right-click on macOS)

Search Integration

  • .searchable() paired with appropriate .searchToolbarBehavior()
  • Search placement makes sense for the platform (bottom bar on iOS, toolbar on macOS)
  • DefaultToolbarItem(kind: .search) used when repositioning is needed

Transitions

  • .matchedTransitionSource applied to ToolbarItem, not its content view
  • Namespace declared with @Namespace at the view level
  • Source ID matches between .matchedTransitionSource and .navigationTransition(.zoom)

Platform

  • Toolbar layouts tested on both iOS and macOS (if multiplatform)
  • Bottom bar items appropriate for small screens
  • Customizable toolbars provided for complex macOS apps

References

レビュー

まだレビューはありません。使ってみた感想をお寄せください。

同じリポジトリのスキル

概要と使いどころ

Run a structured accessibility audit on an iOS/macOS app — automated XCUITest audits, Accessibility Inspector, manual VoiceOver/Dynamic Type passes, and App Store Accessibility Nutrition Label evaluation. Use before release, when preparing Nutrition Label declarations, or for EU Accessibility Act compliance.

日本語の概要は準備中です。原文の説明を表示しています。

rshankras/claude-code-apple-skills7902026年7月24日 更新

Generate accessibility infrastructure for VoiceOver, Dynamic Type, and accessibility features. Use when improving app accessibility, adding accessibility labels and hints, or auditing compliance.

日本語の概要は準備中です。原文の説明を表示しています。

rshankras/claude-code-apple-skills7902026年7月24日 更新

Generates an Apple-compliant account deletion flow with multi-step confirmation UI, optional data export, configurable grace period, Keychain cleanup, and server-side deletion request. Use when user needs account deletion, right-to-delete, or Apple App Review compliance for account removal.

日本語の概要は準備中です。原文の説明を表示しています。

rshankras/claude-code-apple-skills7902026年7月24日 更新

Privacy-preserving ad measurement with AdAttributionKit (SKAdNetwork's successor) — install and re-engagement attribution, conversion-value strategy under crowd anonymity, and end-to-end postback testing. Use when running paid acquisition beyond Apple Ads, measuring re-engagement campaigns, designing conversion values, or migrating from SKAdNetwork.

日本語の概要は準備中です。原文の説明を表示しています。

rshankras/claude-code-apple-skills7902026年7月24日 更新

alarmkit

無料

AlarmKit integration for scheduling alarms and timers with custom UI, Live Activities, and snooze support. Use when implementing alarm or timer features in iOS 26+ apps.

日本語の概要は準備中です。原文の説明を表示しています。

rshankras/claude-code-apple-skills7902026年7月24日 更新

Interpret app metrics and make data-driven decisions. Covers DAU/MAU, retention, LTV, ARPU, App Store Connect analytics, AARRR funnel analysis, cohort analysis, and diagnostic decision trees. Use when user wants to understand their metrics, diagnose problems, or build a data-driven growth plan.

日本語の概要は準備中です。原文の説明を表示しています。

rshankras/claude-code-apple-skills7902026年7月24日 更新

rshankras のスキルをすべて見る

このスキルの問題を報告する