<!--
{
  "availability" : [
    "iOS: 14.0.0 - 27.2.0",
    "iPadOS: 14.0.0 - 27.2.0",
    "macCatalyst: 14.0.0 - 27.2.0",
    "visionOS: 1.0.0 - 27.2.0"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/View/navigationBarTitle(_:displayMode:)-5071t",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI4ViewPAAE18navigationBarTitle_11displayModeQrqd___AA010NavigationE4ItemV0f7DisplayH0OtSyRd__lF"
  },
  "title" : "navigationBarTitle(_:displayMode:)"
}
-->

# navigationBarTitle(_:displayMode:)

Sets the title and display mode in the navigation bar for this view.

```
nonisolated func navigationBarTitle<S>(_ title: S, displayMode: NavigationBarItem.TitleDisplayMode) -> some View where S : StringProtocol
```

## Parameters

`title`

A title for this view to display in the navigation bar.

`displayMode`

The way to display the title.

## Discussion

Use `navigationBarTitle(_:, displayMode)` to set the title of the
navigation bar for this view and specify a display mode for the
title from one of the `NavigationBarItem.Title.DisplayMode`
styles. This modifier only takes effect when this view is inside of and
visible within a `NavigationView`.

In the example below, `navigationBarTitle(_:, displayMode)` uses a
string to provide a title for the navigation bar. Setting the title’s
`displaymode` to `.inline` places the navigation bar title within the
bounds of the navigation bar.

In the example below, text for the navigation bar title is provided using
a string. The navigation bar title’s `displayMode` is set to
`.inline` which places the navigation bar title in the bounds of the
navigation bar.

```
struct FlavorView: View {
    let items = ["Chocolate", "Vanilla", "Strawberry", "Mint Chip",
                 "Pistachio"]
    let title = "Today's Flavors"
    var body: some View {
        NavigationView {
            List(items, id: \.self) {
                Text($0)
            }
            .navigationBarTitle(title, displayMode: .inline)
        }
    }
}
```

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)