accessibilityElement
Controls how a view's child accessibility elements are exposed, mirroring SwiftUI's accessibilityElement(children:). It creates a new accessibility element (or modifies the existing one) and applies the chosen behavior to the subtree.
accessibilityElement(children)
| Parameter | Type | Description |
|---|---|---|
children(optional) | 'contain' | 'ignore' | 'combine' | How the child accessibility elements are treated |
ignore- hide the children; the new element starts with no properties, so pair it withaccessibilityLabel(default).combine- merge the children's accessibility properties into the new element.contain- keep the children as accessible elements, grouped in the new element as a container (navigated in order).
. Default: 'ignore' |
Controls how a view's child accessibility elements are exposed, mirroring SwiftUI's accessibilityElement(children:). It creates a new accessibility element (or modifies the existing one) and applies the chosen behavior to the subtree.
Complements accessibilityHidden, which hides a single leaf, by acting on the whole subtree.
Returns: ModifierConfig
See: Official SwiftUI documentation.
Works with
You can add accessibilityElement to any view. It changes what you see on 20 of the 39 components.
No visible effect
These components accept it, but you see no change.
| Component | Why nothing happens |
|---|---|
| Spacer | It joins the child views into one accessibility element, and Spacer takes no child views. |
| Divider | It joins the child views into one accessibility element, and Divider takes no child views. |
| Button | It joins the child views into one accessibility element, and Button takes no child views. |
| Toggle | It joins the child views into one accessibility element, and Toggle takes no child views. |
| Checkbox | It joins the child views into one accessibility element, and Checkbox takes no child views. |
| Slider | It joins the child views into one accessibility element, and Slider takes no child views. |
| Picker | It joins the child views into one accessibility element, and Picker takes no child views. |
| DatePicker | It joins the child views into one accessibility element, and DatePicker takes no child views. |
| ColorPicker | It joins the child views into one accessibility element, and ColorPicker takes no child views. |
| Link | It joins the child views into one accessibility element, and Link takes no child views. |
| Menu | It joins the child views into one accessibility element, and Menu takes no child views. |
| TextField | It joins the child views into one accessibility element, and TextField takes no child views. |
| SecureField | It joins the child views into one accessibility element, and SecureField takes no child views. |
| Text | It joins the child views into one accessibility element, and Text takes no child views. |
| Label | It joins the child views into one accessibility element, and Label takes no child views. |
| Image | It joins the child views into one accessibility element, and Image takes no child views. |
| ProgressView | It joins the child views into one accessibility element, and ProgressView takes no child views. |
| Gauge | It joins the child views into one accessibility element, and Gauge takes no child views. |
| AccessoryWidgetBackground | It joins the child views into one accessibility element, and AccessoryWidgetBackground takes no child views. |
Sources
The original Expo docs for this page:
- accessibilityElement (Modifiers) (
source-of-truth/versions/v57.0.0/sdk/ui/swift-ui/modifiers.md)