- August 28, 2025
- Mins Read
A KeyboardAvoider for SwiftUI. Inspired by the simplicity of keyboard_avoider in Flutter.
Create a Package.swift file.
import PackageDescription
let package = Package(
name: “TestProject”,
dependencies: [
.package(url: “https://github.com/michaelhenry/KeyboardAvoider.git”, from: “1.0.0”)
]
)
target ‘MyApp’ do
pod ‘KeyboardAvoider’, ‘~> 1.0’
end
import KeyboardAvoider
KeyboardAvoider {
// … Your view with TextFields
}
Example:
KeyboardAvoider {
VStack {
TextField(“First name”, text: self.$firstname)
TextField(“Last name”, text: self.$lastname)
TextField(“Email”, text: self.$email)
TextField(“Password”, text: self.$password)
TextField(“Confirm password”, text: self.$password)
Button(“Sign Up”) {
}
Button(“Already have an account?”) {
}
}
.padding(.horizontal, 16.0)
}
Or in case you don’t want to make your view scrollable, you can just only apply the .avoidKeyboard() into your main view.
VStack {
TextField(“First name”, text: self.$firstname)
TextField(“Last name”, text: self.$lastname)
TextField(“Email”, text: self.$email)
TextField(“Password”, text: self.$password)
TextField(“Confirm password”, text: self.$password)
Button(“Sign Up”) {
}
Button(“Already have an account?”) {
}
}
.avoidKeyboard()
This package provides you with an easy way to show tooltips over any SwiftUI view, since Apple does not provide ...
SimpleToast is a simple, lightweight, flexible and easy to use library to show toasts / popup notifications inside iOS or ...
Create Toast Views with Minimal Effort in SwiftUI Using SSToastMessage. SSToastMessage enables you to effortlessly add toast notifications, alerts, and ...