How set inactive a button in SwiftUI
Disable a SwiftUI button so user cannot tap it.
SOFTWARE DEVELOPMENTIOS DEVELOPMENTSWIFTUI
Eduardo Domínguez Menéndez
7/22/20241 min read
Despite its utility, the .disabled modifier can sometimes be a little hidden within SwiftUI’s extensive list of modifiers. Let's explore it!
By default, buttons in SwiftUI are always tappable, but sometimes you may need to disable them based on certain conditions. The .disabled modifier has this purpose. When the condition or boolean value passed to .disabled is true, the button is deactivated.
.disabled(conditionToDisable)
Now let's see this modifier in a real View:


iPhone Charger with Fast Charging Capability, Type C Wall Charger
The most chargers the best ;)
Apple iPhone 16 Pro, US Version, 128GB, Black Titanium - Unlocked (Renewed)
The iPhone with the best trade off price versus features. This iPhone is ready for Apple Intelligence and it is equipped with LIDAR sensor for your AR Projects or visionOS projects.
Apple 2024 Mac Mini Desktop Computer with M4 chip with 10‑core CPU and 10‑core GPU
The best Mac trade off price versus performance and cutting edge features
Suggested stuff for a developer
The following items are a list of stuff that really help us in our daily workflows as developers. Buying through these Amazon links support this site.