How to use TextField 2.0 in SwiftUI

Kelvin Tan
Swiftly Engineered iOS
3 min readMar 13, 2023

--

Photo by Mel Poole on Unsplash

In WWDC 2021, Apple introduce additional features for TextField further improving the component itself. You may look back at the previous article about TextField that was written by me on how to utilize it’s capabilities to the maximum.

Prerequisites

To follow along this tutorial, you’ll need some basic knowledge in:

  • A basic familiarity with Swift.
  • At least Xcode 13
  • iOS 15+

Submit Label

With submitLabel, you can now choose from a variety of choices for user to tap on whenever they are done with the TextField. This also work on SecureField and TextView.

Some of the choices are:

  1. continue
  2. done
  3. go
  4. join
  5. next
  6. return
  7. route
  8. search
  9. send
TextField("Name", text: $name)
.submitLabel(.next)

On Submit

--

--

Kelvin Tan
Swiftly Engineered iOS

Father, husband, software engineer. Building software and building a family, one line of code and one moment at a time. 🚀💻💙 http://ko-fi.com/kelvintanzy