defaultSectionExpansion(_:)
Sets the default expansion state for the section containing this tab when displayed in the sidebar.
Declaration
nonisolated func defaultSectionExpansion(_ expansion: TabSectionExpansion) -> some TabContent<Self.TabValue>
Parameters
- expansion:
The default expansion behavior for the containing section. The default is Automatic.
Discussion
Use this modifier to control whether a tab section starts expanded or collapsed in the sidebar. The user can manually change the expansion state, and subsequent user interactions take precedence over this default.
This modifier has no effect in contexts where sections are not collapsible — for example, on platforms that do not present a collapsible sidebar, or when automatic is supplied.
TabView {
TabSection("Library") {
Tab("Songs", systemImage: "music.note") {
SongsView()
}
Tab("Albums", systemImage: "square.stack") {
AlbumsView()
}
}
TabSection("Archive") {
Tab("Old Playlists", systemImage: "archivebox") {
ArchiveView()
}
Tab("Deleted", systemImage: "trash") {
DeletedView()
}
}
.defaultSectionExpansion(.collapsed)
}
.tabViewStyle(.sidebarAdaptable)See Also
Configuring tab content
badge(_:)contextMenu(menuItems:)customizationBehavior(_:for:)customizationID(_:)TabSectionExpansiondefaultVisibility(_:for:)disabled(_:)draggable(_:)dropDestination(for:action:)help(_:)hidden(_:)popover(isPresented:attachmentAnchor:arrowEdge:content:)popover(item:attachmentAnchor:arrowEdge:content:)sectionActions(content:)springLoadingBehavior(_:)