Skip to content

Instantly share code, notes, and snippets.

@romyios
Created July 20, 2022 18:31
Show Gist options
  • Save romyios/c2a80458dd3264027431908e486d0de9 to your computer and use it in GitHub Desktop.
Save romyios/c2a80458dd3264027431908e486d0de9 to your computer and use it in GitHub Desktop.
This is so nice! It's always a pain in the ass to do this stuff
// https://stackoverflow.com/a/72067001/1492368
struct TextFieldTest: View {
@FocusState private var emailFocused: Bool
@FocusState private var passwordFocused: Bool
@State private var username: String = ""
@State private var password: String = ""
var body: some View {
TextField("User name (email address)", text: $username)
.focused($emailFocused)
.onSubmit {
passwordFocused = true
}
TextField("Enter Password", text: $password)
.focused($passwordFocused)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment