Compose SwiftUIv0.4.0
esc
GuideAPIGitHub
View

TabView

A view that switches between child views with a tab bar.

iOS 17.0+macOS 14.0+tvOS 17.0+watchOS 10.0+
fun TabView(modifier: Modifier = Modifier, content: @Composable () -> Unit)

Overview

Give each child a Tab. With TabView(selection, onSelectionChange) the selected tab is Kotlin state, so your code can switch tabs.

TabView(selection = tab, onSelectionChange = { tab = it }) {
    Tab("Home", systemImage = SFSymbol.house, value = AppTab.Home) { HomeScreen() }
    Tab("Settings", systemImage = SFSymbol.gear, value = AppTab.Settings) { SettingsScreen() }
}

This is the Kotlin form of SwiftUI TabView.init(content:): SwiftUI documentation. In Swift it reads:

nonisolated init(@ContentBuilder content: () -> Content)

Topics

Creating a TabView

fun TabView(modifier: Modifier = Modifier, content: @Composable () -> Unit)
SwiftUI TabView.init(content:)