Logo for tanaschita.com

Customizing the appearance of the NavigationStack title in SwiftUI

Learn how to create a custom navigation bar title view in SwiftUI using NavigationStack.

20 Jan 2025 · 3 min read

When working with NavigationStack, we have the possibility to customize the appearance of the navigation bar, including the title. This article explores two approaches to creating custom titles using SwiftUI’s navigationBarTitleDisplayMode(_:) and toolbar(content:) modifiers.

Let's jump in.

Sponsorship logo
Architecture & Design Patterns for iOS
This book is a practical guide to essential architectural principles and design patterns for iOS development. It covers strategies for building maintainable apps with Swift and SwiftUI, including dependency injection, navigation, common patterns, and modularization.
LEARN MORE

The Default Title Behavior

In NavigationStack, a title is displayed when the navigationTitle(_:) modifier is used. By default, the system employs a large title that transitions to an inline title when scrolling:

NavigationStack {
VStack {
// Content...
}
.navigationTitle("Inline Title")
}

If we want to move beyond the default behavior, we can use the following customization techniques.

Customizing with navigationBarTitleDisplayMode(_:)

The navigationBarTitleDisplayMode(_:) modifier lets us control how the navigation title appears. Setting the mode to .inline ensures that the title remains compact and inline at all times, even when scrolling. This creates a consistent look across the app, particularly for minimalistic designs.

NavigationStack {
VStack {
// Content...
}
.navigationTitle("Inline Title")
.navigationBarTitleDisplayMode(.inline)
}

Adding Custom Title Views with toolbar(content:)

To fully customize the appearance of the navigation title, the toolbar(content:) modifier allows replacing the default title with any SwiftUI view. By specifying a ToolbarItem with a placement of .principal, we can override the default title and insert completely custom layouts:

NavigationStack {
VStack {
// Content...
}
.navigationTitle("Custom Title")
.navigationBarTitleDisplayMode(.inline)
.toolbar {
ToolbarItem(placement: .principal) {
Image(systemName: "photo.fill")
.font(.title)
.foregroundColor(.blue)
}
}
}

Instead of an Image, we can use any SwiftUI view.

Sponsorship logo
Preparing for a technical iOS job interview
Preparing for a technical iOS Job Interview with over 300 questions & answers. Covering Swift & Objective-C, SwiftUI & UIKit, Combine, HTTP Networking, iOS File System, Core Data, Concurrency with async/await, Security, Automated Testing, Dependency Management, AI & Machine Learning and more.
LEARN MORE
Sponsorship logo
Architecture & Design Patterns for iOS
This book is a practical guide to essential architectural principles and design patterns for iOS development. It covers strategies for building maintainable apps with Swift and SwiftUI, including dependency injection, navigation, common patterns, and modularization.
LEARN MORE
Sponsorship logo
Become a sponsor of tanaschita.com
By publishing an article on different iOS topics every week, tanaschita.com is constantly growing in the developer community and may provide a great audience for you as a sponsor.
CLICK TO LEARN MORE

Newsletter

Image of a reading marmot
Subscribe

Like to support my work?

Say hi

Related tags

Articles with related topics

navigation

swiftui

swift

ios

How to persist navigation state in SwiftUI

Learn how to save and restore NavigationPath to maintain user context across app launches.

21 Apr 2025 · 4 min read

Latest articles and tips

© 2026 tanaschita.com

Privacy policy

Impressum