Declaration
compose().contentToolbar({
for: SwiftUI.ContentToolbarPlacement,
content: ReactNode,
})nonisolated func contentToolbar<Content>(
for placement: ContentToolbarPlacement,
@ToolbarContentBuilder content: () -> Content
) -> some View
where Content : ToolbarContent1 more Swift overload share this form
nonisolated func contentToolbar<Content>(
for placement: ContentToolbarPlacement,
@ContentBuilder content: () -> Content
) -> some View
where Content : ViewParameters
options.for*SwiftUI.ContentToolbarPlacementoptions.content*ReactNodeThe views representing the content of the toolbar.
Discussion
Use this modifier to add toolbar content that remains consistent
regardless of the content view. Use a toolbar modifier within the
content view if the toolbar content is dependent the content view is
showing.
Unlike the toolbar modifier, which configures the toolbar of the
modified view's container, the contentToolbar modifier configures the
toolbar within the modified view's content instead. This means that the
contentToolbar modifier should generally be applied directly to a
container view, instead of to the content within a container view. For
example, to configure the toolbar of tab view's sidebar, apply the
contentToolbar modifier to the TabView itself, not to any of the
tabs within the TabView.
The content toolbar modifier expects a collection of toolbar items that
you can provide by either supplying a collection of views with each view
wrapped in a ToolbarItem, or by providing a collection of views as a
ToolbarItemGroup. The example below adds an account summary to the
bottom of the tab view sidebar and a button to the tab view sidebar
overflow menu.
TabView {
Tab("Home", systemImage: "house") {
HomeView()
}
Tab("Alerts", systemImage: "bell") {
AlertsView()
}
TabSection("Categories") {
Tab("Climate", systemImage: "fan") {
ClimateView()
}
Tab("Lights", systemImage: "lightbulb") {
LightsView()
}
}
}
.tabViewStyle(.sidebarAdaptable)
.contentToolbar(for: .tabViewSidebar) {
ToolbarItem(placement: .automatic) {
DisconnectDevicesButton()
}
ToolbarItem(placement: .bottomBar) {
AccountSummaryView()
}
}See also
More in Navigation.
- assistiveAccessNavigationIconConfigures the view's icon for purposes of navigation.
- asyncImageURLSessionA modifier that adds a URL session for asynchronous images contained in the view to use when fetching image data.
- defaultAdaptableTabBarPlacementSpecifies the default placement for the tabs in a tab view using the adaptable sidebar style.
- defaultTabBarPlacementSpecifies the preferred placement for the tabs of a TabView in the TabViewStyle.sidebarAdaptable style on platforms where the tab bar cannot adapt between different representations, and only one representation can be shown.
- navigationBarBackButtonHiddenHides the navigation bar back button for the view.
- navigationBarTitleDisplayModeConfigures the title display mode for this view.
- navigationDestinationAssociates a destination view with a presented data type for use within a navigation stack.
- navigationDocumentConfigures the view's document for purposes of navigation.
- navigationLinkIndicatorVisibilityConfigures whether navigation links show a disclosure indicator.
- navigationSplitViewColumnWidthSets a fixed, preferred width for the column containing this view.
- navigationSubtitleConfigures the view's subtitle for purposes of navigation, using a localized string resource.
- navigationTitleConfigures the view's title for purposes of navigation, using a localized string resource.