Built-in animatable tab buttons
mainWhile you can use any custom view as a tab button, the library provides two built-in button types that support specific animations out-of-the-box:
DropletButtonWiggleButton
repository·main·Indexed 19 days ago
https://github.com/exyte/animatedtabbarA SwiftUI library for implementing interactive tab navigation with preset animations. Features customizable ball trajectories (parabolic, teleport, straight), adjustable visual styles, and built-in animatable buttons like DropletButton and WiggleButton. Requires iOS 16+ and Xcode 14+.
While you can use any custom view as a tab button, the library provides two built-in button types that support specific animations out-of-the-box:
DropletButtonWiggleButtonTo use AnimatedTabBar, follow these steps:
@State Int to track the current selection.AnimatedTabBar using one of two methods:AnyView.selectedIndex: A Binding<Int> to the current selection index.views: The buttons to display in the tab bar.import AnimatedTabBar
// Method 1: View Builder
AnimatedTabBar(selectedIndex: $selectedIndex) {
TabButton1()
TabButton2()
TabButton3()
}
// Method 2: Array of views
AnimatedTabBar(selectedIndex: $selectedIndex, views: [TabButton1(), TabButton2(), TabButton3()])Add the following dependency to your Package.swift file to include AnimatedTabBar in your project.
dependencies: [
.package(url: "https://github.com/exyte/AnimatedTabBar.git")
]Ensure your environment meets the following minimum requirements:
You can customize the appearance and behavior of the tab bar using the customize closure in the popup modifier.
barColor: Color of the tabbar background.selectedColor: Color for the selected tab (use template rendering for proper application).unselectedColor: Color for unselected tabs.ballColor: Color of the ball indicator.verticalPadding: Space between the buttons and the bar's top/bottom edges.cornerRadius: Corner radius for the tabbar background.ballAnimation: Animation curve for the ball motion (default is .easeOut(duration: 0.6)).indentAnimation: Animation curve for the growing/shrinking of the indent.buttonsAnimation: Animation curve for applying color to tab buttons.ballTrajectory: Defines the path of the ball indicator:.parabolic: Jumps to the selected button following a parabolic arc..teleport: Disappears and quickly re-appears above the selected tab..straight: Slides directly to the selected tab.didSelectIndex: A closure called every time a tab is tapped.