SwiftUI.cc
Snippets
State UIOther ModifiersBeginner

SwiftUI disabled, redacted, and allowsHitTesting

Represent unavailable, loading, private, and pass-through states with the right interaction and visual modifiers.

4 min readUpdated 2026-06
Loading card with safe action
import SwiftUI

struct LoadingProfileCard: View {
    let isLoading: Bool
    let canSave: Bool

    var body: some View {
        VStack(alignment: .leading, spacing: 12) {
            Text("Taylor Chen").font(.headline)
            Text("iOS Engineer").foregroundStyle(.secondary)

            Button("Save") {}
                .disabled(!canSave || isLoading)
        }
        .padding()
        .redacted(reason: isLoading ? .placeholder : [])
    }
}
Use this when

A control should be visible but unavailable until requirements are met.

A loading view should preserve the final layout while content arrives.

An overlay should be visible without blocking controls underneath.

Avoid this when

The user needs an explanation for why the action is unavailable; add helper text.

Redaction hides interactive controls that should not be tappable yet.

Pass-through hit testing creates surprising behavior behind opaque views.

Implementation notes

disabled is inherited by descendants, which is useful for forms but surprising on large containers.
redacted is visual; pair it with disabled when controls should not be used during loading.
allowsHitTesting(false) lets events pass through a view, which is useful for decorative overlays.

Checklist

Do not rely on disabled appearance alone; explain blocked actions when needed.

Use unredacted for labels or controls that must remain visible.

Verify skeleton layouts match the final content footprint.

Related reference