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
- Creating a Tappable Button
- Styling Buttons
- Running Code on Tap
- Disabling & Enabling Buttons