- July 26, 2025
- Mins Read
Create main button view and a number of submenu buttons — both should be cast to AnyView
type.
Pass both to FloatingButton
constructor:
FloatingButton(mainButtonView: mainButton, buttons: buttons)
You may also pass a binding which will determine if the menu is currently open. You may use this to close the menu on any submenu button tap for example.
FloatingButton(mainButtonView: mainButton, buttons: buttons, isOpen: $isOpen)
.straight()
or .circle()
to specify desired menu type.
FloatingButton(mainButtonView: mainButton, buttons: textButtons)
.straight()
.direction(.top)
.alignment(.left)
.spacing(10)
.initialOffset(x: -1000)
.animation(.spring())
FloatingButton(mainButtonView: mainButton2, buttons: buttonsImage.dropLast())
.circle()
.startAngle(3/2 * .pi)
.endAngle(2 * .pi)
.radius(70)
.layoutDirection(.counterClockwise)
spacing
– space between submenu buttons
initialScaling
– size multiplyer for submenu buttons when the menu is closed
initialOffset
– offset for submenu buttons when the menu is closed
initialOpacity
– opacity for submenu buttons when the menu is closed
animation
– custom SwiftUI animation like Animation.easeInOut()
or Animation.spring()
delays
– delay for each submenu button’s animation start – you can pass array of delays – one for each element – or you can pass delayDelta
– then this same delay will be used for each element mainZStackAlignment
– main button and submenu buttons are contained in one ZStack (not an overlay so the menu has a correct size), you can change this ZStack’s alignment with this parameter inverseZIndex
– inverse zIndex of mainButton and the children. Use, for example, if you have a negative spacing and want to change the order wholeMenuSize
– pass CGSize binding to get updates of menu’s size. Menu’s size includes main button frame and all of elements’ frames menuButtonsSize
– pass CGSize binding to get updates of combined menu elements’ size
direction
– position of submenu buttons relative to main menu button
alignment
– alignment of submenu buttons relative to main menu button
startAngle
endAngle
radius
– distance between center of main button and centers of submenu buttons
layoutDirection
– changes the button layout direction from the startAngle to the endAngle
To try the FloatingButton examples:
https://github.com/exyte/FloatingButton.git
FloatingButtonExample.xcodeproj
in the Xcode
dependencies: [
.package(url: “https://github.com/exyte/FloatingButton.git”)
]
NavigationKit is a lightweight library which makes SwiftUI navigation super easy to use. 💻 Installation 📦 Swift Package Manager Using Swift Package Manager, add ...
An alternative SwiftUI NavigationView implementing classic stack-based navigation giving also some more control on animations and programmatic navigation. NavigationStack Installation ...
With SwiftUI Router you can power your SwiftUI app with path-based routing. By utilizing a path-based system, navigation in your app becomes ...
This package takes SwiftUI's familiar and powerful NavigationStack API and gives it superpowers, allowing you to use the same API not just ...