0PricingLogin
SwiftUI Academy · Lesson

Binding a TextField to State

Connect a text field to a @State string.

Meet TextField

A TextField is SwiftUI's box where users type. Give it a prompt and somewhere to store what they enter, and you have live text input. ✍️

Text Needs a Home

Typed characters must go somewhere. You store them in a @State string that the text field reads from and writes to as the user types.

@State private var name = ""

All lessons in this course

  1. Binding a TextField to State
  2. Keyboard Types & Placeholders
  3. SecureField for Passwords
  4. Live Input Validation
← Back to SwiftUI Academy