TabView is used in SwiftUI to organize an app into multiple main sections using tabs.
It allows apps to:
switch between top-level screens
group major sections of the app
keep navigation simple and structured
Core flow:
TabView → Tab Items → Selected Tab Content
TabView displays different views based on the currently selected tab.
It is commonly used for:
home screen sections
main app navigation
switching between independent areas
Each tab usually represents a major part of the app.
TabView {
HomeView()
.tabItem {
Label("Home", systemImage: "house")
}
ProfileView()
.tabItem {
Label("Profile", systemImage: "person")
}
}
Here:
TabView → container for tabs
tabItem → label for each tab
HomeView / ProfileView → content for each tab
Each screen inside TabView uses .tabItem to define its tab button.