These modifiers govern whether a component is shown to the user, whether it responds to taps and clicks, and whether its text can be selected.Documentation Index
Fetch the complete documentation index at: https://docs.metabind.ai/llms.txt
Use this file to discover all available pages before exploring further.
hidden keeps the component in the layout but invisible; allowsHitTesting lets touches pass through without changing appearance; disabled blocks interaction and dims the visuals; textSelection toggles selectability of text content.
Pick by intent — visibility (hidden), interaction (allowsHitTesting, disabled), or selection (textSelection). For full transparency without removing hit testing, use opacity instead.
hidden
Hides the component while preserving its layout space..opacity(0), .hidden() also removes the component from hit testing — it will not respond to taps or other gestures. The component’s layout space is still reserved. To remove a component from the layout entirely, conditionally exclude it from the view tree instead of using .hidden().
allowsHitTesting
Controls whether a component receives touch or click events.When
false, the component and all its descendants become transparent to touch and click events. Events pass through to views behind it.allowsHitTesting(false) does not dim the component visually. It only affects whether the component receives interaction events.
disabled
Disables interaction with a component and dims its appearance.When
true, the component and its descendants cannot receive interaction events. The component is also visually dimmed.disabled(true) both prevents interaction and applies a visual dimming effect. To prevent interaction without the visual change, use allowsHitTesting(false) instead.
textSelection
Enables or disables user text selection.Whether text selection is enabled or disabled.
See also
- opacity — control transparency without affecting layout
- contentShape — change the hit-testing shape
- onTapGesture — add tap handling to non-interactive components
- accessibilityHidden — hide from assistive technologies