Contents

isTabViewSidebarAvailable

A Boolean value that indicates whether a tab sidebar is available within the content of a surrounding Tabview.

Declaration

var isTabViewSidebarAvailable: Bool { get }

Discussion

This value is only meaningful inside the content views of a TabView that uses a sidebar-capable style such as sidebarAdaptable. Reading it from a view that is not nested inside a TabView’s content — for example, a view above the TabView in the hierarchy — returns false.

struct ContentView: View {
    var body: some View {
        TabView {
            Tab("Home", systemImage: "house") {
                HomeTab()
            }
        }
        .tabViewStyle(.sidebarAdaptable)
    }
}

struct HomeTab: View {
    @Environment(\.isTabViewSidebarAvailable)
    private var isTabViewSidebarAvailable

    var body: some View {
        if isTabViewSidebarAvailable {
            // Sidebar is (or can become) visible — adjust UI.
        } else {
            // No sidebar in this context.
        }
    }
}

Use this value to gate behaviors or UI that depend on the sidebar’s availability, rather than inspecting size classes directly.