KeyboardAvoider
  • August 20, 2025

Screenshot Screenshot

⌨️ KeyboardAvoider {}


 

KeyboardAvoider for SwiftUI. Inspired by the simplicity of keyboard_avoider in Flutter.

Features


 

  • Autoscroll to TextField
  • Swipe keyboard to dismiss

Installation


 

Swift Package Manager

 

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”)
]
)

Cocoapods

target ‘MyApp’ do
pod ‘KeyboardAvoider’, ‘~> 1.0’
end

How to use


 

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()

GitHub


View Github

YOU MIGHT ALSO LIKE...
TextView

Download File -> Swift Packages -> Add Package Dependency... Select your project Enter https://github.com/kenmueller/TextView for the package repository URL Select Branch: master Click Finish ...

Focuser

Focuser allows to focus SwiftUI text fields dynamically and implements ability move go through the form using Keyboard for iOS ...

OmenTextField

A better TextField for SwiftUI. A growing, multiline, auto-focusable TextField supporting bindable focus. This has been pulled out of my ...

iPhoneNumberField ☎️

Format phone numbers as they're typed—entirely in SwiftUI. 📱   Get Started | Examples | Customize | Features | Install | Pricing And it's as easy as

CurrencyText

CurrencyText provides lightweight libraries for formating text field text as currency, available for both UIKit and SwiftUI. Its main core, the CurrencyFormatter class, can also ...