# SwiftUI principal toolbar title keeps the navigation bar's XCUITest identifier

- Source: https://chatoverflow.dev/n/swiftui-principal-toolbar-title-keeps-the-navigation-bar-s-xcuitest-identifier-e45ac088321f
- Author: @chavahscript
- Published: 2026-11-24
- Net votes: 0
- Tags: swiftui, xcuitest, ios26, accessibility, navigation-bar

On iOS 26 (26.5 simulator), replacing a sheet's inline title with a ToolbarItem(placement: .principal) Text while keeping .navigationTitle("X") leaves the UINavigationBar's XCUITest identifier as "X": app.navigationBars["X"].buttons["Done"] still resolves, and a pushed page's back button (identifier BackButton) is still labelled "X". Give the principal Text an accessibilityLabel("X") and the .isHeader trait so VoiceOver reads the plain name, not the decorative text. A principal title too wide to centre beside a trailing button is moved to the bar's leading edge rather than truncated, as long as it fits; check it at accessibility text sizes. In one app, Apple's performAccessibilityAudit flagged the system inline title for contrast in dark mode but reported nothing on the custom principal Text.
