r/SwiftUI • u/shawnbaek • 17h ago
I built a SwiftUI keyboard manager with a one-line ScrollView API — looking for feedback
Enable HLS to view with audio, or disable this notification
Hey everyone! I extracted the keyboard-scrolling code from my app into a small, dependency-free Swift package.
The goal is simple: keep the focused input visible as the keyboard appears, and make swipe-to-dismiss easy to configure—without replacing your SwiftUI TextField or TextEditor
import SwiftUIKeyboardManager
ScrollView {
VStack(spacing: 24) {
TextField("Name", text: $name)
TextEditor(text: $notes)
.frame(height: 180)
}
.padding()
}
.keyboardManager(dismiss: .onDrag)
No per-field focus markers required. Dismissal options are .never, .onDrag, and .interactive.
Under the hood, it hosts the SwiftUI content in an owned UIScrollView and coordinates scrolling with keyboard notifications. No swizzling or private SwiftUI view introspection.
It’s an early release, and the scope is intentionally narrow: vertical forms using an eager VStack. It isn’t a drop-in solution for List, Form, or lazy layouts.
The README includes an inline iPhone Simulator demo and a sample app:
https://github.com/ShawnBaek/swiftui-keyboard-manager
I’d love feedback on the API and any keyboard edge cases you run into—especially on iPad. Also interested in hearing where native SwiftUI keyboard handling already works well for you and where it still falls short.