Skip to content
Center Action Tab preview
Rendered from the SwiftUI source on this page.

Center Action Tab

From syxUI — written for both platforms, not translated between them.

A bottom tab bar with a prominent center action.

Navigation · SwiftUI · iOS 17

  • navigation
  • swiftui

The actual source

FabTabBar.swift
// Center Action Tab · syxUI · https://syxui.dev/components/nav2-fab-tab
// Free in any project. Keep this line and credit syxUI where a person can read it.

import SwiftUI

let navBlue = Color(red: 0.0, green: 0.47, blue: 1.0)

// Bottom tab with prominent center action
struct FabTabBar: View {
    @State private var sel = 0
    let left = [("house.fill", "Home"), ("magnifyingglass", "Search")]
    let right = [("bell.fill", "Alerts"), ("person.fill", "You")]
    var body: some View {
        HStack(spacing: 0) {
            ForEach(Array(left.enumerated()), id: \.offset) { i, t in
                VStack(spacing: 4) { Image(systemName: t.0).font(.system(size: 19)); Text(t.1).font(.system(size: 10)) }.foregroundStyle(sel == i ? navBlue : .secondary).frame(maxWidth: .infinity).onTapGesture { sel = i }
            }
            HStack(spacing: 6) { Image(systemName: "plus"); Text("Create").font(.system(size: 14, weight: .semibold)) }.foregroundStyle(.white).padding(.horizontal, 16).padding(.vertical, 11).background(navBlue, in: Capsule()).padding(.horizontal, 8)
            ForEach(Array(right.enumerated()), id: \.offset) { i, t in
                VStack(spacing: 4) { Image(systemName: t.0).font(.system(size: 19)); Text(t.1).font(.system(size: 10)) }.foregroundStyle(.secondary).frame(maxWidth: .infinity).onTapGesture { sel = i + 2 }
            }
        }.padding(.top, 8).padding(.bottom, 6).overlay(alignment: .top) { Divider() }.frame(width: 370)
    }
}
iOS 17 · No dependencies

Dependencies

SwiftUI
No external dependencies

Requires iOS 17