0Pricing
SwiftUI Academy · Lesson

Disabling & Enabling Buttons

Control interactivity with the disabled modifier.

Sometimes Tapping Should Wait

Not every button should always be tappable. A submit button might wait until a form is valid. SwiftUI handles this with the disabled modifier. 🚦

The disabled Modifier

Add disabled to any control and pass true or false. When true, the button stops responding to taps right away.

Button("Send") { send() }
    .disabled(true)

All lessons in this course

  1. Creating a Tappable Button
  2. Styling Buttons
  3. Running Code on Tap
  4. Disabling & Enabling Buttons
← Back to SwiftUI Academy