How to Add Bar Items to a Navigation View in SwiftUI

July 9, 2025·1 min read·by dockui

How to Add Bar Items to a Navigation View in SwiftUI

Let’s walk through how to add bar items the easy way, and how to customize where they show up.

Adding Buttons to the Navigation Bar

Here’s a simple example that adds two buttons to the top-right corner of a navigation view.

Code Snippet

Customizing Button Placement

Want to control exactly where your buttons go? Use ToolbarItem and set the .placement.

Here's how to add a back-style button on the leading side of the navigation bar:

Code Snippet

This gives you more control and can help with readability, and design alignment.

Recap

  • Use .toolbar to easily add items to your navigation view.
  • Use ToolbarItem with .placement to control where things go.

Bar items are a small thing, but they make your app feel complete and native. 🎉

Similar Blogs

View All Articles
How to Navigate to Another View in SwiftUI

How to Navigate to Another View in SwiftUI

Starting from iOS 16, Apple introduced the new NavigationStack API, which replaces NavigationView and makes navigation more powerful and reliable.

by dockui
Oct 13
SwiftUI: iOS Confirmation Alert (Confirm + Cancel)

SwiftUI: iOS Confirmation Alert (Confirm + Cancel)

SwiftUI iOS confirmation alert with Confirm and Cancel buttons. Beginners guide to building safe actions, destructive deletes, and commit dialogs.

by dockui
Nov 11
SwiftUI: How To Reset a Form

SwiftUI: How To Reset a Form

Learn how to reset a SwiftUI form with one line. Clear text fields instantly using @State or a form model. Simple copy/paste SwiftUI code examples.

by dockui
Nov 10
SwiftUI: How To Toggle a Switch Programmatically

SwiftUI: How To Toggle a Switch Programmatically

Learn how to toggle a SwiftUI switch programmatically with @State and @Binding. Simple examples with code to trigger Toggle from buttons or other views.

by dockui
Nov 10

Code copied to clipboard!