
Tab Switcher
From syxUI — written for both platforms, not translated between them.
A two-tab underline switcher.
Navigation · SwiftUI · iOS 17
- navigation
- swiftui
The actual source
TabSwitcher.swift
// Tab Switcher · syxUI · https://syxui.dev/components/nav2-tab-switcher
// 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)
// Two big tab switcher
struct TabSwitcher: View {
@State private var sel = 0
var body: some View {
HStack(spacing: 0) {
ForEach(Array(["Following", "For You"].enumerated()), id: \.offset) { i, t in
VStack(spacing: 8) {
Text(t).font(.system(size: 16, weight: sel == i ? .bold : .medium)).foregroundStyle(sel == i ? Color.primary : Color.secondary)
Capsule().fill(sel == i ? navBlue : .clear).frame(width: 30, height: 3)
}.frame(maxWidth: .infinity).onTapGesture { sel = i }
}
}.frame(width: 280)
}
}
iOS 17 · No dependencies
Dependencies
- SwiftUI
- No external dependencies
Requires iOS 17


