<!--
{
  "availability" : [
    "iOS: 27.0.0 -",
    "iPadOS: 27.0.0 -",
    "macCatalyst: 27.0.0 -",
    "macOS: 27.0.0 -",
    "tvOS: 27.0.0 -",
    "visionOS: 27.0.0 -",
    "watchOS: 27.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/TabContent/defaultSectionExpansion(_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI10TabContentPAAE23defaultSectionExpansionyQrAA0cfG0VF"
  },
  "title" : "defaultSectionExpansion(_:)"
}
-->

# defaultSectionExpansion(_:)

Sets the default expansion state for the section containing this
tab when displayed in the sidebar.

```
nonisolated func defaultSectionExpansion(_ expansion: TabSectionExpansion) -> some TabContent<Self.TabValue>
```

## Parameters

`expansion`

The default expansion behavior for the
containing section. The default is
[`automatic`](/documentation/SwiftUI/TabSectionExpansion/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`](/documentation/SwiftUI/TabSectionExpansion/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)
```

---

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)