Member-only story
Floating button in SwiftUI
2 min readApr 30, 2024

The Apple User Interface Guidelines don’t mention floating buttons, and there is no native component for them. However, some applications, such as Twitter and the Gmail client, do use them.
In this post, we’ll explore how to create a floating button, taking the Gmail app client as our example.
We aim to create this:

Therefore, we need to create a TabView. Inside the first tab, we’ll use a ZStack that contains both a list and a button.
struct ContentView: View {
var body: some View {
TabView {
NavigationStack {
ZStack {
List(initList(), id:\.self) { mail in
Text(mail)
}
VStack {
Spacer()
HStack {
Spacer()
NavigationLink { EmptyView()} label:{
Image(systemName: "pencil")
.font(.title.weight(.semibold))
.padding()
.background(.pink)
.foregroundStyle(.white)…