TechnologiesSwiftUI

TabBarMinimizeBehavior struct

iOSmacOStvOSwatchOSvisionOSiOS 26.0+✓ renders

How it works

TabBarMinimizeBehavior describes when a TabView's tab bar should collapse into a compact form to yield screen space to the content beneath it. It gives you a small, type-safe vocabulary of policies — such as minimizing as the user scrolls down — that you hand to the tabBarMinimizeBehavior(_:) modifier rather than tracking scroll offsets and animating the bar yourself. Reach for it when a scroll-heavy tab should let its content take over the screen while keeping the tab bar one gesture away, the way Apple's own apps shrink the bar as you read and restore it when you scroll back.

  1. Apply the behavior with tabBarMinimizeBehavior(_:)

    TabBarMinimizeBehavior takes effect through the tabBarMinimizeBehavior(_:) modifier, which you attach to the TabView (or a view that contains it). The modifier reads the value and configures how the system manages the tab bar's collapsed and expanded states. In the example, .tabBarMinimizeBehavior(.onScrollDown) is placed directly on the TabView, so the policy governs every tab it presents.

  2. Choose a policy with the type's static members

    You rarely construct a TabBarMinimizeBehavior directly; instead you select one of its predefined values, written in leading-dot form because the modifier's parameter is already typed. The example passes .onScrollDown, which tells SwiftUI to minimize the bar while the user scrolls down through content and bring it back as they scroll up — automatic state that you'd otherwise have to drive by hand.

  3. Give the behavior something to scroll

    A scroll-driven policy like .onScrollDown only changes anything when a tab actually scrolls, so the symbol pairs naturally with scrolling content. Here the Home Tab wraps a ScrollView, and as that view scrolls the tab bar minimizes; the Search tab holds only a static Text, so within it there is nothing for the behavior to react to.

  4. Inherit across the tabs of one TabView

    Because the modifier is applied to the TabView itself rather than to an individual Tab, the chosen TabBarMinimizeBehavior is the bar's policy for the whole tab interface. The Home and Search tabs share the same minimize behavior, so switching tabs doesn't reset or re-specify it.

Try it — Change .tabBarMinimizeBehavior(.onScrollDown) to .tabBarMinimizeBehavior(.automatic) (or remove the modifier entirely) and scroll the Home tab to watch the tab bar stay fixed instead of collapsing.

Example & preview

Press Run live & edit to compile it in your browser — then edit the Swift on the left and the preview re-renders live.

TabBarMinimizeBehavior.swift
struct TabBarMinimizeBehaviorDemo: View {
    var body: some View {
        TabView {
            Tab("Home", systemImage: "house") {
                ScrollView {
                    ForEach(1..<30) { i in
                        Text("Row \(i)")
                            .frame(maxWidth: .infinity, alignment: .leading)
                            .padding()
                    }
                }
            }
            Tab("Search", systemImage: "magnifyingglass") {
                Text("Search")
            }
        }
        .tabBarMinimizeBehavior(.onScrollDown)
    }
}
Live preview
Row 1 Row 2 Row 3 Row 4 Row 5 Row 6 Row 7 Row 8 Row 9 Row 10 Row 11 Row 12 Row 13 Row 14 Row 15 Row 16 Row 17 Row 18 Row 19 Row 20 Row 21 Row 22 Row 23 Row 24 Row 25 Row 26 Row 27 Row 28 Row 29 Home Home
Row 1 Row 2 Row 3 Row 4 Row 5 Row 6 Row 7 Row 8 Row 9 Row 10 Row 11 Row 12 Row 13 Row 14 Row 15 Row 16 Row 17 Row 18 Row 19 Row 20 Row 21 Row 22 Row 23 Row 24 Row 25 Row 26 Row 27 Row 28 Row 29 Home Home
swift → lexer → parser → sema → uiir → canvas Open in Studio ↗
What's new in SwiftUI 27 →