Modern SwiftUI toolbar patterns including customizable toolbars, search integration, transition effects, and platform-specific behavior. Use when implementing or customizing toolbars in SwiftUI.
npx skills add https://github.com/rshankras/claude-code-apple-skills --skill toolbars
Modern toolbar patterns for SwiftUI apps. Covers customizable toolbars, enhanced search integration, new placements, transition effects, and platform-specific considerations.
Use this skill when the user:
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 | Minimum Version | Notes |
|-----|----------------|-------|
| .toolbar { } | iOS 14 | Basic toolbar |
| ToolbarItem(placement:) | iOS 14 | Standard placements |
| .toolbar(id:) | iOS 16 | Customizable toolbars |
| ToolbarItem(id:) | iOS 16 | Items in customizable toolbars |
| ToolbarSpacer | iOS 16 | Fixed and flexible spacers |
| .searchable() | iOS 15 | Search integration |
| .searchToolbarBehavior(.minimize) | iOS 17 | Minimized search button |
| DefaultToolbarItem(kind:placement:) | iOS 18 | Reposition system items |
| ToolbarItem(placement: .largeSubtitle) | iOS 18 | Subtitle area content |
| .matchedTransitionSource(id:in:) | iOS 18 | Toolbar transition source |
| .sharedBackgroundVisibility() | iOS 18 | Glass background control |
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()
}
}
ToolbarSpacer(.fixed) // Fixed-width space
ToolbarSpacer(.flexible) // Flexible space — pushes items apart
// ❌ 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()
}
}
Renders search field as a compact button that expands on tap:
@State private var searchText = ""
NavigationStack {
RecipeList()
.searchable(text: $searchText)
.searchToolbarBehavior(.minimize)
}
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()
}
}
}
Reposition system items with custom placements:
.toolbar {
DefaultToolbarItem(kind: .search, placement: .bottomBar)
DefaultToolbarItem(kind: .sidebar, placement: .navigationBarLeading)
}
Place custom content in the navigation bar subtitle area:
NavigationStack {
DetailView()
.navigationTitle("Title")
.navigationSubtitle("Subtitle")
.toolbar {
ToolbarItem(placement: .largeSubtitle) {
CustomLargeNavigationSubtitle()
}
}
}
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))
}
}
}
}
Control the shared glass background on toolbar items:
ContentView()
.toolbar(id: "main") {
ToolbarItem(id: "build-status", placement: .principal) {
BuildStatus()
}
.sharedBackgroundVisibility(.hidden)
}
| # | Mistake | Fix |
|---|---------|-----|
| 1 | Missing id on ToolbarItem in customizable toolbar | Every item in .toolbar(id:) must have its own id parameter |
| 2 | Using .searchToolbarBehavior(.minimize) without .searchable() | Must pair with .searchable() modifier — .minimize only affects rendering |
| 3 | Putting .matchedTransitionSource on the Button instead of ToolbarItem | Apply .matchedTransitionSource(id:in:) on the ToolbarItem, not its content |
| 4 | Using .largeSubtitle alongside .navigationSubtitle() expecting both to show | .largeSubtitle takes precedence — the subtitle modifier value is hidden |
| 5 | Forgetting placement: on DefaultToolbarItem | Without explicit placement, system items use their default position |
| Platform | Recommendations |
|----------|----------------|
| iOS | Bottom bar useful on iPhones. Use .searchToolbarBehavior(.minimize) for space efficiency. |
| iPadOS | Customizable toolbars valuable in productivity apps. Consider keyboard shortcuts. |
| macOS | Users expect toolbar customization. Use spacers for logical groupings. |
.toolbar(id:) has a unique, stable string identifierToolbarItem within has its own unique id.searchable() paired with appropriate .searchToolbarBehavior()DefaultToolbarItem(kind: .search) used when repositioning is needed.matchedTransitionSource applied to ToolbarItem, not its content view@Namespace at the view level.matchedTransitionSource and .navigationTransition(.zoom)Integration with protocols.io API for managing scientific protocols. This skill should be used when working with protocols.io to search, create, update, or publish protocols; manage protocol steps and materials; handle discussions and comments; organize workspaces; upload and manage files; or integrate protocols.io functionality into workflows. Applicable for protocol discovery, collaborative protocol development, experiment tracking, lab protocol management, and scientific documentation.
Analyzes job descriptions and generates tailored resumes that highlight relevant experience, skills, and achievements to maximize interview chances
Generate Excalidraw diagrams from natural language descriptions. Use when asked to "create a diagram", "make a flowchart", "visualize a process", "draw a system architecture", "create a mind map", or "generate an Excalidraw file". Supports flowcharts, relationship diagrams, mind maps, and system architecture diagrams. Outputs .excalidraw JSON files that can be opened directly in Excalidraw.
Build and distribute Expo development clients locally or via TestFlight
Use when you have a written implementation plan to execute in a separate session with review checkpoints
Data structure for annotated matrices in single-cell analysis. Use when working with .h5ad files or integrating with the scverse ecosystem. This is the data format skill—for analysis workflows use scanpy; for probabilistic models use scvi-tools; for population-scale queries use cellxgene-census.
Benchling R&D platform integration. Access registry (DNA, proteins), inventory, ELN entries, workflows via API, build Benchling Apps, query Data Warehouse, for lab data management automation.
Comprehensive molecular biology toolkit. Use for sequence manipulation, file parsing (FASTA/GenBank/PDB), phylogenetics, and programmatic NCBI/PubMed access (Bio.Entrez). Best for batch processing, custom bioinformatics pipelines, BLAST automation. For quick lookups use gget; for multi-service integration use bioservices.
Take rshankras/toolbars from the repository into ~/.claude/skills for personal
use, or into .claude/skills inside a project.
The agent identifies a skill by the name field in its header. Two skills with the
same name cannot sit side by side — one of them will be ignored.