A custom SwiftUI implementation of a modern, scrollable tab bar with smooth animations and expandable search functionality, inspired by modern iOS design patterns.
- π― Dual Capsule Design: Two separate capsules - one for scrollable tabs, one for search
- π± 7 Scrollable Tabs: Horizontally scrollable tab bar with smooth auto-centering
- π΅ Sliding Selection Indicator: Animated blue background that slides between selected tabs
- π Expandable Search: Search button that expands into a full search bar
- β¨ Smooth Animations: Beautiful transitions using SwiftUI's latest animation APIs
- π¨ Material Background: Ultra-thin material backgrounds for a modern look
- iOS 16.0+
- Xcode 14.0+
- SwiftUI
- Clone the repository:
git clone https://github.com/yourusername/iOS26TabBarLike.git
cd iOS26TabBarLike- Open the project in Xcode:
open iOS26TabBarLike.xcodeproj- Build and run the project on your simulator or device.
The project consists of three main components:
Defines the available tabs with their icons and labels:
enum TabItem: String, CaseIterable, Equatable {
case recents = "Recents"
case shared = "Shared"
case browse = "Browse"
case albums = "Albums"
case search = "Search"
case library = "Library"
case forYou = "For You"
var symbol: String {
// Returns appropriate SF Symbol for each tab
}
}The main tab bar component featuring:
- Horizontal scroll view with 7 tabs
- Sliding selection indicator using
matchedGeometryEffect - Expandable search functionality
- Auto-scroll to selected tab
The main container that:
- Manages tab selection state
- Displays content for each tab
- Coordinates between tab bar and content views
.background {
if activeTab == tab {
Capsule()
.fill(Color.blue)
.matchedGeometryEffect(id: "activeTab", in: animation)
}
}.onChange(of: activeTab) { newTab in
withAnimation(.smooth(duration: 0.3)) {
proxy.scrollTo(newTab, anchor: .center)
}
}// Main tab bar hides when search expands
if !isSearchExpanded {
ScrollViewReader { proxy in
// Tab bar content
}
.transition(.asymmetric(
insertion: .move(edge: .leading).combined(with: .opacity),
removal: .move(edge: .leading).combined(with: .opacity)
))
}struct ContentView: View {
@State private var activeTab: TabItem = .recents
var body: some View {
ZStack(alignment: .bottom) {
TabContentView(tab: activeTab)
CustomTabBar(activeTab: $activeTab)
}
}
}To add or modify tabs:
- Update the
TabItemenum with your new cases - Add corresponding SF Symbols in the
symbolcomputed property - The tab bar will automatically accommodate the new tabs
// Change accent color
var accentColor: Color {
return .blue // Change to your preferred color
}
// Modify background material
.background {
Capsule()
.fill(.ultraThinMaterial) // Try .regularMaterial or .thickMaterial
}- State Management: Using
@Stateand@Bindingfor reactive UI updates - Namespace: For
matchedGeometryEffectanimations - ViewBuilder: For clean, reusable view components
- ScrollViewReader: For programmatic scroll control
- FocusState: For keyboard management in search
- Duration: Consistent 0.3-second animations throughout
- Easing:
.smooth()animation curve for natural feel - Transitions: Asymmetric slide transitions for tab switching
- Lazy Loading: Content views are only created when needed
- Efficient Scrolling: ScrollView with optimized content rendering
- Memory Management: Proper state cleanup when switching tabs
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Inspired by modern iOS design patterns
- Built with SwiftUI's latest animation capabilities
- SF Symbols for beautiful, consistent iconography
If you have any questions or need help implementing this in your project:
- Open an issue on GitHub
- Follow the implementation guide above
- Check out the demo video for visual reference
Made with β€οΈ using SwiftUI


