
Badged Tab Bar
From syxUI — written for both platforms, not translated between them.
A bottom tab bar with notification count badges.
Navigation · SwiftUI · iOS 17
- navigation
- swiftui
The actual source
BadgedTabBar.swift
// Badged Tab Bar · syxUI · https://syxui.dev/components/nav2-badged-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)
// Tab bar with badges
struct BadgedTabBar: View {
@State private var sel = 0
let tabs: [(String, String, Int)] = [("house.fill", "Home", 0), ("bell.fill", "Alerts", 3), ("bubble.left.fill", "Chats", 12), ("person.fill", "You", 0)]
var body: some View {
HStack {
ForEach(Array(tabs.enumerated()), id: \.offset) { i, t in
VStack(spacing: 4) {
Image(systemName: t.0).font(.system(size: 20)).overlay(alignment: .topTrailing) {
if t.2 > 0 { Text("\(t.2)").font(.system(size: 9, weight: .bold)).foregroundStyle(.white).padding(.horizontal, 4).padding(.vertical, 2).frame(minWidth: 16).background(.red, in: Capsule()).offset(x: 11, y: -6) }
}
Text(t.1).font(.system(size: 10, weight: .medium))
}.foregroundStyle(sel == i ? navBlue : Color.secondary).frame(maxWidth: .infinity).onTapGesture { sel = i }
}
}.padding(.top, 10).padding(.bottom, 8).overlay(alignment: .top) { Divider() }.frame(width: 360)
}
}
iOS 17 · No dependencies
Dependencies
- SwiftUI
- No external dependencies
Requires iOS 17


