To create a SwiftUI custom tab bar, define an enum for your tabs and store the selected case in a @State property (a value SwiftUI watches and redraws the screen for). Then draw your own bar with buttons at the bottom of a ZStack or safeAreaInset. Show the content for the selected tab above it. Keep every tab’s view alive so each NavigationStack remembers its own path. The steps below build this from scratch, including how to hide the default tab bar and how to keep content from sliding under your bar.
How a custom tab bar works
A tab bar is only two things. The first is a piece of state that says which screen is active. The second is a row of buttons that change that state.
The native TabView (the built-in SwiftUI tab container, also called a tab view) does both for you, but it limits how far you can restyle the bar. When you build it yourself, the state is an enum value, the buttons are plain SwiftUI views, and the screens are switched based on that value. The code below targets SwiftUI on iOS 17 and later.

Step 1: Define the tabs with an enum
An enum (a type with a fixed list of cases) keeps the tab list type-safe. Make it CaseIterable so you can loop over it to draw the bar, and Identifiable so ForEach accepts it.
enum AppTab: String, CaseIterable, Identifiable {
case home, search, favorites, profile
var id: String { rawValue }
var title: String {
switch self {
case .home: "Home"
case .search: "Search"
case .favorites: "Favorites"
case .profile: "Profile"
}
}
var icon: String {
switch self {
case .home: "house"
case .search: "magnifyingglass"
case .favorites: "heart"
case .profile: "person"
}
}
}
Check: the file compiles. Adding a new case makes the compiler flag both switches until you give it a title and an icon. The icon is an SF Symbol name, one of Apple’s built-in icons.
Step 2: Add state-driven selection
The root view owns the selection. Because the bar and the content both read the same value, a single change updates both. You can also switch tabs programmatically from anywhere that holds a binding to it.
struct RootView: View {
@State private var selection: AppTab = .home
var body: some View {
ZStack {
ForEach(AppTab.allCases) { tab in
content(for: tab)
.opacity(selection == tab ? 1 : 0)
.allowsHitTesting(selection == tab)
}
}
.safeAreaInset(edge: .bottom, spacing: 0) {
CustomTabBar(selection: $selection)
}
}
@ViewBuilder
private func content(for tab: AppTab) -> some View {
switch tab {
case .home: HomeTab()
case .search: SearchTab()
case .favorites: FavoritesTab()
case .profile: ProfileTab()
}
}
}
All four screens stay in the hierarchy and only the selected one is visible. This is deliberate, and Step 5 explains why.
Using safeAreaInset also answers the question of how to place content above the bar. The inset shrinks the safe area, so scroll views and lists stop above the bar instead of running under it.
Check: the last row of a long list can be scrolled fully above the bar.

Step 3: Build the custom bar view with icons and labels
The bar is a horizontal stack of buttons. Each button shows an icon above a label. The selected one gets a highlight that slides between tabs using matchedGeometryEffect, which animates a shape from one position to another.
struct CustomTabBar: View {
@Binding var selection: AppTab
@Namespace private var highlight
var body: some View {
HStack {
ForEach(AppTab.allCases) { tab in
Button {
withAnimation(.spring(response: 0.35, dampingFraction: 0.8)) {
selection = tab
}
} label: {
VStack(spacing: 4) {
Image(systemName: selection == tab ? tab.icon + ".fill" : tab.icon)
.font(.system(size: 20))
Text(tab.title)
.font(.caption2)
}
.frame(maxWidth: .infinity)
.padding(.vertical, 8)
.foregroundStyle(selection == tab ? Color.accentColor : .secondary)
.background {
if selection == tab {
Capsule()
.fill(Color.accentColor.opacity(0.15))
.matchedGeometryEffect(id: "highlight", in: highlight)
}
}
}
.buttonStyle(.plain)
.accessibilityLabel(tab.title)
.accessibilityAddTraits(selection == tab ? .isSelected : [])
}
}
.padding(.horizontal, 12)
.padding(.top, 8)
.background(.bar)
}
}
The withAnimation block is what makes tab switching animated. The .fill suffix works for many SF Symbols but not all, so confirm each icon exists in the SF Symbols app.
Check: tapping a tab moves the highlight smoothly. VoiceOver (Apple’s screen reader) announces the tab name and its selected state.
Step 4: Hide the native tab bar
In the approach above there is no native bar to hide, because we never use TabView. That is the cleanest answer to the common question of how to hide the default tab bar. If you prefer to keep TabView for its lifecycle behavior, hide its bar instead.
TabView(selection: $selection) {
HomeTab().tag(AppTab.home)
SearchTab().tag(AppTab.search)
FavoritesTab().tag(AppTab.favorites)
ProfileTab().tag(AppTab.profile)
}
.toolbar(.hidden, for: .tabBar)
.safeAreaInset(edge: .bottom, spacing: 0) {
CustomTabBar(selection: $selection)
}
The newer Tab syntax is an alternative way to declare tabs, and the same .toolbar(.hidden, for: .tabBar) modifier still applies to the container. Older tutorials also suggest UITabBar.appearance().isHidden. That is a UIKit workaround (UIKit is Apple’s older interface framework) and less reliable in modern SwiftUI.
Check: run on a device and confirm only your bar appears, with no second bar underneath.

Step 5: Keep NavigationStack state per tab
Each tab needs its own NavigationStack, so every tab has separate navigation inside it. Since Step 2 keeps all tabs in memory, every stack keeps its path when the user leaves and returns. If you used a switch to show only the current tab, SwiftUI would destroy the other stacks and the user would lose their place.
struct HomeTab: View {
@State private var path = NavigationPath()
var body: some View {
NavigationStack(path: &path) {
List(1...30, id: \.self) { number in
NavigationLink("Item \(number)", value: number)
}
.navigationTitle("Home")
.navigationDestination(for: Int.self) { number in
Text("Detail \(number)")
}
}
}
}
Owning the path also lets you pop to the root when the user taps the already selected tab. Detect the repeat tap in the button action:
// In the bar button action
if selection == tab {
onReselect(tab) // reset that tab's path here
} else {
selection = tab
}
To make this work, hold one path per tab in a small @Observable router object. Then clear the matching path inside onReselect.
Check: push two screens in Home, switch to Search, come back, and you are still on the second screen.
Common pitfalls
- Content hidden behind the bar. Cause: the bar sits in a plain
ZStackoverlay. Fix: usesafeAreaInset(edge: .bottom)so the layout accounts for the bar height. - Navigation resets on every tab change. Cause: the content is chosen by a
switch, so inactive tabs are removed. Fix: keep all tabs in the hierarchy, as in Step 2, or store paths outside the views. - Two bars appear. Cause: a
TabViewis still showing its native bar. Fix: add.toolbar(.hidden, for: .tabBar). - Hidden tabs still react to taps or load work. Cause: opacity alone does not disable a view. Fix: add
allowsHitTestingand, if needed,accessibilityHiddenon inactive tabs. - Bar overlaps the home indicator on some devices. Cause: ignoring the bottom safe area on the background only is easy to get wrong. Fix: let the
.barmaterial background extend, but keep the buttons inside the safe area.
Custom bar, TabView styling, or tabViewBottomAccessory
Customizing the native bar is the lowest-effort route. You can change colors with modifiers such as toolbarBackground and tint. You can also apply the tabViewStyle modifier to pick a different TabViewStyle, for example the page style, which shows horizontal scrolling pages and suits onboarding. On iPadOS, the sidebarAdaptable style lets the tab bar turn into a sidebar. However, you cannot freely change the bar’s shape, layout or animation.
The tabViewBottomAccessory modifier, available on the newest OS versions, serves another purpose. It attaches an extra view, such as a mini player, above the native tab bar. It extends the system bar rather than replacing it, so it will not give you a fully custom design.
| Approach | Design freedom | System behavior | Best for |
|---|---|---|---|
| Custom bar | Full | You rebuild it, including accessibility | Branded, unusual layouts |
| Styled TabView | Limited | Kept automatically | Standard apps |
| tabViewBottomAccessory | Extra view only | Kept automatically | Persistent controls like players |
Which approach fits you
Choose the custom bar when your design needs a shape, animation or placement the system bar cannot offer. Accept that you then maintain accessibility and iPad behavior yourself.
Choose a styled TabView for most apps, and add tabViewBottomAccessory when you only need a persistent control above the bar. Start with the enum and selection from Steps 1 and 2 in a small test project, then compare it with the native bar on a real device before committing.