TabViewBottomAccessoryPlacement

A placement of the bottom accessory in a tab view. You can use this to adjust the content of the accessory view based on the placement.

EnumerationiOS 26.0+macOS 26.0+tvOS 26.0+watchOS 26.0+visionOS 26.0+TabViewBottomAccessoryPlacement in SwiftUI

Declaration

React
type TabViewBottomAccessoryPlacement = SwiftOpaque<'TabViewBottomAccessoryPlacement'>;
Swift
enum TabViewBottomAccessoryPlacement

Overview

The following example shows playback controls when the view is inline, and an expanded slider player view when the view is expanded.

struct MusicPlaybackView: View {
    @Environment(\.tabViewBottomAccessoryPlacement) var placement

    var body: some View {
        switch placement {
        case .inline:
            ControlsPlaybackView()
        case .expanded:
            SliderPlaybackView()
    }
}

You can set the TabView bottom accessory using View.tabViewBottomAccessory(content:)

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

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

    TabSection("Categories") {
        Tab("Climate", systemImage: "fan") {
            ClimateView()
        }

        Tab("Lights", systemImage: "lightbulb") {
            LightsView()
        }
    }
}
.tabViewBottomAccessory {
    HomeStatusView()
}

From Apple’s SwiftUI documentation. Code samples there are Swift.

See also

More in Navigation.