Skip to content
Floating Tab Bar preview
Rendered from the SwiftUI source on this page.

Floating Tab Bar

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

A detached floating pill tab bar with a shadow.

Navigation · SwiftUI · iOS 17

  • navigation
  • swiftui

The actual source

FloatPillTab.swift
// Floating Tab Bar · syxUI · https://syxui.dev/components/nav2-float-pill
// 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)

// Floating detached pill tab bar
struct FloatPillTab: View {
    @State private var sel = 0
    let icons = ["house.fill", "magnifyingglass", "plus", "bell.fill", "person.fill"]
    var body: some View {
        HStack(spacing: 26) {
            ForEach(Array(icons.enumerated()), id: \.offset) { i, ic in
                Image(systemName: ic).font(.system(size: 21)).foregroundStyle(sel == i ? navBlue : Color.secondary).onTapGesture { sel = i }
            }
        }.padding(.horizontal, 24).padding(.vertical, 15).background(Color(.systemBackground), in: Capsule()).shadow(color: .black.opacity(0.06), radius: 10, y: 4).overlay(Capsule().stroke(Color.primary.opacity(0.08)))
    }
}
iOS 17 · No dependencies

Dependencies

SwiftUI
No external dependencies

Requires iOS 17