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. 🎉

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
How to use @AppStorage in SwiftUI

How to use @AppStorage in SwiftUI

Learn how to use @AppStorage in SwiftUI to save user settings and preferences easily with UserDefaults

by dockui
Oct 17
How to Make Text Selectable in SwiftUI

How to Make Text Selectable in SwiftUI

Learn how to make text selectable in SwiftUI using the .textSelection(.enabled) modifier. Enable text copying and selection easily in iOS 15 and later with

by dockui
Oct 13
How to Dismiss a Sheet in SwiftUI

How to Dismiss a Sheet in SwiftUI

In this guide, you’ll learn the modern way to dismiss a sheet in SwiftUI, how it works, and how to make it fully compatible with your existing code.

by dockui
Oct 12
How to request users to review your SwiftUI app

How to request users to review your SwiftUI app

Learn how to properly ask users for App Store reviews in your SwiftUI app using StoreKit. Boost ratings by timing your requests at the right user moments.

by dockui
Jul 2
SwiftUI vs UIKit in 2025: Which Is Better?

SwiftUI vs UIKit in 2025: Which Is Better?

Learn which framework to choose, how to mix both, and when UIKit still makes sense for iOS app development.

by dockui
Oct 17

Code copied to clipboard!