tabViewSidebarHeader

Adds a custom header to the sidebar of a tab view.

View ModifieriOS 18.0+macOS 15.0+tvOS 27.0+visionOS 2.0+tabViewSidebarHeader(content:) in SwiftUI

Declaration

React
compose().tabViewSidebarHeader({
  content: ReactNode,
})
Swift
nonisolated func tabViewSidebarHeader<Content>(
    @ContentBuilder content: () -> Content
) -> some View
where Content : View

Parameters

  • options.content*ReactNode

Discussion

The header appears at the top of the sidebar before any tab labels and can scroll with the content. The header is only visible when the TabView is displaying the sidebar.

The following example adds a welcome message to the top of the sidebar:

TabView {
    Tab("Home", systemImage: "house") {
        HomeView()
    }

    Tab("Alerts", systemImage: "bell") {
        AlertsView()
    }

    Tab("Browse", systemImage: "list.bullet") {
        MyBrowseView()
    }
}
.tabViewStyle(.sidebarAdaptable)
.tabViewSidebarHeader {
    WelcomeHeaderView()
}

See also

More in Navigation.