{% setvar book_path %}/reference/androidx/_book.yaml{% endsetvar %} {% include "_shared/_reference-head-tags.html" %}

SemanticsPropertyReceiver

public interface SemanticsPropertyReceiver

Known direct subclasses
SemanticsConfiguration

Describes the semantic information associated with the owning component


SemanticsPropertyReceiver is the scope provided by semantics {} blocks, letting you set key/value pairs primarily via extension functions.

Summary

Public methods

abstract void
<T extends Object> set(@NonNull SemanticsPropertyKey<@NonNull T> key, @NonNull T value)

Extension functions

default final void
SemanticsPropertiesKt.collapse(
    @NonNull SemanticsPropertyReceiver receiver,
    String label,
    Function0<@NonNull Boolean> action
)

Action to collapse an expandable node.

default final void
SemanticsPropertiesKt.copyText(
    @NonNull SemanticsPropertyReceiver receiver,
    String label,
    Function0<@NonNull Boolean> action
)

Action to copy the text to the clipboard.

default final void
SemanticsPropertiesKt.cutText(
    @NonNull SemanticsPropertyReceiver receiver,
    String label,
    Function0<@NonNull Boolean> action
)

Action to cut the text and copy it to the clipboard.

default final void

Whether this element is a Dialog.

default final void

Whether this semantics node is disabled.

default final void
SemanticsPropertiesKt.dismiss(
    @NonNull SemanticsPropertyReceiver receiver,
    String label,
    Function0<@NonNull Boolean> action
)

Action to dismiss a dismissible node.

default final void

Mark semantics node that contains invalid input or error.

default final void
SemanticsPropertiesKt.expand(
    @NonNull SemanticsPropertyReceiver receiver,
    String label,
    Function0<@NonNull Boolean> action
)

Action to expand an expandable node.

default final @NonNull CollectionInfo

This semantics marks node as a collection and provides the required information.

default final @NonNull CollectionItemInfo

This semantics marks node as an items of a collection and provides the required information.

default final @NonNull String

Developer-set content description of the semantics node.

default final @NonNull List<@NonNull CustomAccessibilityAction>

Custom actions which are defined by app developers.

default final @NonNull AnnotatedString

Input text of the text field with visual transformation applied to it.

default final boolean

Whether this semantics node is focused.

default final @NonNull ScrollAxisRange

The horizontal scroll state of this node if this node is scrollable.

default final @NonNull ImeAction

Contains the IME action provided by the node.

default final @NonNull LiveRegionMode

This node is marked as live region for accessibility.

default final @NonNull String

Accessibility-friendly title for a screen's pane.

default final @NonNull ProgressBarRangeInfo

The semantics is represents a range of possible values with a current value.

default final @NonNull Role

The type of user interface element.

default final boolean

Whether this element is selected (out of a list of possible selections).

default final @NonNull String

Developer-set state description of the semantics node.

default final @NonNull String

Test tag attached to this semantics node.

default final boolean

Configuration toggle to map testTags to resource-id.

default final @NonNull AnnotatedString

Text of the semantics node.

default final void

Action to get a Text/TextField node's TextLayoutResult.

default final @NonNull TextRange

Text selection range for the text field.

default final @NonNull ToggleableState

The state of a toggleable component.

default final float

A value to manually control screenreader traversal order.

default final @NonNull ScrollAxisRange

The vertical scroll state of this node if this node is scrollable.

default final void

The node is marked as heading for accessibility.

default final void

The index of an item identified by a given key.

default final void

Action to insert text into this node at the current cursor position, or replacing the selection if text is selected.

default final void

Whether this node is specially known to be invisible to the user.

default final boolean

Whether this semantics node is a container.

default final boolean

Whether this semantics node is a traversal group.

default final void
SemanticsPropertiesKt.onClick(
    @NonNull SemanticsPropertyReceiver receiver,
    String label,
    Function0<@NonNull Boolean> action
)

Action to be performed when the node is clicked (single-tapped).

default final void
SemanticsPropertiesKt.onLongClick(
    @NonNull SemanticsPropertyReceiver receiver,
    String label,
    Function0<@NonNull Boolean> action
)

Action to be performed when the node is long clicked (long-pressed).

default final void
SemanticsPropertiesKt.pageDown(
    @NonNull SemanticsPropertyReceiver receiver,
    String label,
    Function0<@NonNull Boolean> action
)

Action to page down.

default final void
SemanticsPropertiesKt.pageLeft(
    @NonNull SemanticsPropertyReceiver receiver,
    String label,
    Function0<@NonNull Boolean> action
)

Action to page left.

default final void
SemanticsPropertiesKt.pageRight(
    @NonNull SemanticsPropertyReceiver receiver,
    String label,
    Function0<@NonNull Boolean> action
)

Action to page right.

default final void
SemanticsPropertiesKt.pageUp(
    @NonNull SemanticsPropertyReceiver receiver,
    String label,
    Function0<@NonNull Boolean> action
)

Action to page up.

default final void

The node is marked as a password.

default final void
SemanticsPropertiesKt.pasteText(
    @NonNull SemanticsPropertyReceiver receiver,
    String label,
    Function0<@NonNull Boolean> action
)

This function adds the SemanticsActions.PasteText to the SemanticsPropertyReceiver.

default final void
SemanticsPropertiesKt.performImeAction(
    @NonNull SemanticsPropertyReceiver receiver,
    String label,
    Function0<@NonNull Boolean> action
)

Action to invoke the IME action handler configured on the node.

default final void

Whether this semantics node represents a Popup.

default final void
SemanticsPropertiesKt.requestFocus(
    @NonNull SemanticsPropertyReceiver receiver,
    String label,
    Function0<@NonNull Boolean> action
)

Action that gives input focus to this node.

default final void
SemanticsPropertiesKt.scrollBy(
    @NonNull SemanticsPropertyReceiver receiver,
    String label,
    Function2<@NonNull Float, @NonNull Float, @NonNull Boolean> action
)

Action to scroll by a specified amount.

default final void
SemanticsPropertiesKt.scrollToIndex(
    @NonNull SemanticsPropertyReceiver receiver,
    String label,
    @NonNull Function1<@NonNull Integer, @NonNull Boolean> action
)

Action to scroll a container to the index of one of its items.

default final void

The node is marked as a collection of horizontally or vertically stacked selectable elements.

default final void

This semantics marks node as a collection and provides the required information.

default final void

This semantics marks node as an items of a collection and provides the required information.

default final void
SemanticsPropertiesKt.setContainer(
    @NonNull SemanticsPropertyReceiver receiver,
    boolean isContainer
)

Whether this semantics node is a container.

default final void

Developer-set content description of the semantics node.

default final void

Custom actions which are defined by app developers.

default final void

Input text of the text field with visual transformation applied to it.

default final void
SemanticsPropertiesKt.setFocused(
    @NonNull SemanticsPropertyReceiver receiver,
    boolean focused
)

Whether this semantics node is focused.

default final void

The horizontal scroll state of this node if this node is scrollable.

default final void

Contains the IME action provided by the node.

default final void

This node is marked as live region for accessibility.

default final void

Accessibility-friendly title for a screen's pane.

default final void
SemanticsPropertiesKt.setProgress(
    @NonNull SemanticsPropertyReceiver receiver,
    String label,
    Function1<@NonNull Float, @NonNull Boolean> action
)

Action to set the current value of the progress bar.

default final void

The semantics is represents a range of possible values with a current value.

default final void

The type of user interface element.

default final void
SemanticsPropertiesKt.setSelected(
    @NonNull SemanticsPropertyReceiver receiver,
    boolean selected
)

Whether this element is selected (out of a list of possible selections).

default final void

Action to set text selection by character index range.

default final void

Developer-set state description of the semantics node.

default final void

Test tag attached to this semantics node.

default final void

Configuration toggle to map testTags to resource-id.

default final void

Text of the semantics node.

default final void
SemanticsPropertiesKt.setText(
    @NonNull SemanticsPropertyReceiver receiver,
    String label,
    Function1<@NonNull AnnotatedString, @NonNull Boolean> action
)

Action to set the text contents of this node.

default final void

Text selection range for the text field.

default final void

The state of a toggleable component.

default final void
SemanticsPropertiesKt.setTraversalGroup(
    @NonNull SemanticsPropertyReceiver receiver,
    boolean isTraversalGroup
)

Whether this semantics node is a traversal group.

default final void
SemanticsPropertiesKt.setTraversalIndex(
    @NonNull SemanticsPropertyReceiver receiver,
    float traversalIndex
)

A value to manually control screenreader traversal order.

default final void

The vertical scroll state of this node if this node is scrollable.

Public methods

set

abstract void <T extends Object> set(@NonNull SemanticsPropertyKey<@NonNull T> key, @NonNull T value)

Extension functions

SemanticsPropertiesKt.collapse

default final void SemanticsPropertiesKt.collapse(
    @NonNull SemanticsPropertyReceiver receiver,
    String label,
    Function0<@NonNull Boolean> action
)

Action to collapse an expandable node.

Parameters
String label

Optional label for this action.

Function0<@NonNull Boolean> action

Action to be performed when the SemanticsActions.Collapse is called.

SemanticsPropertiesKt.copyText

default final void SemanticsPropertiesKt.copyText(
    @NonNull SemanticsPropertyReceiver receiver,
    String label,
    Function0<@NonNull Boolean> action
)

Action to copy the text to the clipboard.

Parameters
String label

Optional label for this action.

Function0<@NonNull Boolean> action

Action to be performed when the SemanticsActions.CopyText is called.

SemanticsPropertiesKt.cutText

default final void SemanticsPropertiesKt.cutText(
    @NonNull SemanticsPropertyReceiver receiver,
    String label,
    Function0<@NonNull Boolean> action
)

Action to cut the text and copy it to the clipboard.

Parameters
String label

Optional label for this action.

Function0<@NonNull Boolean> action

Action to be performed when the SemanticsActions.CutText is called.

SemanticsPropertiesKt.dialog

default final void SemanticsPropertiesKt.dialog(
    @NonNull SemanticsPropertyReceiver receiver
)

Whether this element is a Dialog. Not to be confused with if this element is part of a Dialog.

SemanticsPropertiesKt.disabled

default final void SemanticsPropertiesKt.disabled(
    @NonNull SemanticsPropertyReceiver receiver
)

Whether this semantics node is disabled. Note that proper SemanticsActions should still be added when this property is set.

See also
Disabled

SemanticsPropertiesKt.dismiss

default final void SemanticsPropertiesKt.dismiss(
    @NonNull SemanticsPropertyReceiver receiver,
    String label,
    Function0<@NonNull Boolean> action
)

Action to dismiss a dismissible node.

Parameters
String label

Optional label for this action.

Function0<@NonNull Boolean> action

Action to be performed when the SemanticsActions.Dismiss is called.

SemanticsPropertiesKt.error

default final void SemanticsPropertiesKt.error(
    @NonNull SemanticsPropertyReceiver receiver,
    @NonNull String description
)

Mark semantics node that contains invalid input or error.

Parameters
@NonNull String description

a localized description explaining an error to the accessibility user

SemanticsPropertiesKt.expand

default final void SemanticsPropertiesKt.expand(
    @NonNull SemanticsPropertyReceiver receiver,
    String label,
    Function0<@NonNull Boolean> action
)

Action to expand an expandable node.

Parameters
String label

Optional label for this action.

Function0<@NonNull Boolean> action

Action to be performed when the SemanticsActions.Expand is called.

SemanticsPropertiesKt.getCollectionInfo

default final @NonNull CollectionInfo SemanticsPropertiesKt.getCollectionInfo(
    @NonNull SemanticsPropertyReceiver receiver
)

This semantics marks node as a collection and provides the required information.

SemanticsPropertiesKt.getCollectionItemInfo

default final @NonNull CollectionItemInfo SemanticsPropertiesKt.getCollectionItemInfo(
    @NonNull SemanticsPropertyReceiver receiver
)

This semantics marks node as an items of a collection and provides the required information.

If you mark items of a collection, you should also be marking the collection with collectionInfo.

SemanticsPropertiesKt.getContentDescription

default final @NonNull String SemanticsPropertiesKt.getContentDescription(
    @NonNull SemanticsPropertyReceiver receiver
)

Developer-set content description of the semantics node.

If this is not set, accessibility services will present the text of this node as the content.

This typically should not be set directly by applications, because some screen readers will cease presenting other relevant information when this property is present. This is intended to be used via Foundation components which are inherently intractable to automatically describe, such as Image, Icon, and Canvas.

SemanticsPropertiesKt.getCustomActions

default final @NonNull List<@NonNull CustomAccessibilityActionSemanticsPropertiesKt.getCustomActions(
    @NonNull SemanticsPropertyReceiver receiver
)

Custom actions which are defined by app developers.

SemanticsPropertiesKt.getEditableText

default final @NonNull AnnotatedString SemanticsPropertiesKt.getEditableText(
    @NonNull SemanticsPropertyReceiver receiver
)

Input text of the text field with visual transformation applied to it. It must be a real text entered by the user with visual transformation applied on top of the input text instead of a developer-set content description.

SemanticsPropertiesKt.getFocused

default final boolean SemanticsPropertiesKt.getFocused(
    @NonNull SemanticsPropertyReceiver receiver
)

Whether this semantics node is focused. The presence of this property indicates this node is focusable

See also
Focused

SemanticsPropertiesKt.getHorizontalScrollAxisRange

default final @NonNull ScrollAxisRange SemanticsPropertiesKt.getHorizontalScrollAxisRange(
    @NonNull SemanticsPropertyReceiver receiver
)

The horizontal scroll state of this node if this node is scrollable.

SemanticsPropertiesKt.getImeAction

default final @NonNull ImeAction SemanticsPropertiesKt.getImeAction(
    @NonNull SemanticsPropertyReceiver receiver
)

Contains the IME action provided by the node.

For example, "go to next form field" or "submit".

A node that specifies an action should also specify a callback to perform the action via performImeAction.

SemanticsPropertiesKt.getLiveRegion

default final @NonNull LiveRegionMode SemanticsPropertiesKt.getLiveRegion(
    @NonNull SemanticsPropertyReceiver receiver
)

This node is marked as live region for accessibility. This indicates to accessibility services they should automatically notify the user about changes to the node's content description or text, or to the content descriptions or text of the node's children (where applicable). It should be used with caution, especially with assertive mode which immediately stops the current audio and the user does not hear the rest of the content. An example of proper use is a Snackbar which is marked as LiveRegionMode.Polite.

SemanticsPropertiesKt.getPaneTitle

default final @NonNull String SemanticsPropertiesKt.getPaneTitle(
    @NonNull SemanticsPropertyReceiver receiver
)

Accessibility-friendly title for a screen's pane. For accessibility purposes, a pane is a visually distinct portion of a window, such as the contents of a open drawer. In order for accessibility services to understand a pane's window-like behavior, you should give descriptive titles to your app's panes. Accessibility services can then provide more granular information to users when a pane's appearance or content changes.

See also
PaneTitle

SemanticsPropertiesKt.getProgressBarRangeInfo

default final @NonNull ProgressBarRangeInfo SemanticsPropertiesKt.getProgressBarRangeInfo(
    @NonNull SemanticsPropertyReceiver receiver
)

The semantics is represents a range of possible values with a current value. For example, when used on a slider control, this will allow screen readers to communicate the slider's state.

SemanticsPropertiesKt.getRole

default final @NonNull Role SemanticsPropertiesKt.getRole(
    @NonNull SemanticsPropertyReceiver receiver
)

The type of user interface element. Accessibility services might use this to describe the element or do customizations. Most roles can be automatically resolved by the semantics properties of this element. But some elements with subtle differences need an exact role. If an exact role is not listed in Role, this property should not be set and the framework will automatically resolve it.

SemanticsPropertiesKt.getSelected

default final boolean SemanticsPropertiesKt.getSelected(
    @NonNull SemanticsPropertyReceiver receiver
)

Whether this element is selected (out of a list of possible selections).

The presence of this property indicates that the element is selectable.

SemanticsPropertiesKt.getStateDescription

default final @NonNull String SemanticsPropertiesKt.getStateDescription(
    @NonNull SemanticsPropertyReceiver receiver
)

Developer-set state description of the semantics node.

For example: on/off. If this not set, accessibility services will derive the state from other semantics properties, like ProgressBarRangeInfo, but it is not guaranteed and the format will be decided by accessibility services.

SemanticsPropertiesKt.getTestTag

default final @NonNull String SemanticsPropertiesKt.getTestTag(
    @NonNull SemanticsPropertyReceiver receiver
)

Test tag attached to this semantics node.

This can be used to find nodes in testing frameworks:

SemanticsPropertiesKt.getTestTagsAsResourceId

@ExperimentalComposeUiApi
default final boolean SemanticsPropertiesKt.getTestTagsAsResourceId(
    @NonNull SemanticsPropertyReceiver receiver
)

Configuration toggle to map testTags to resource-id.

This provides a way of filling in AccessibilityNodeInfo.viewIdResourceName, which in the View System is populated based on the resource string in the XML.

testTags are also provided in AccessibilityNodeInfo.extras under key "androidx.compose.ui.semantics.testTag". However, when using UIAutomator or on Android 7 and below, extras are not available, so a more backwards-compatible way of making testTags available to accessibility-tree-based integration tests is sometimes needed. resource-id was the most natural property to repurpose for this.

This property applies to a semantics subtree. For example, if it's set to true on the root semantics node of the app (and no child nodes set it back to false), then every testTag will be mapped.

SemanticsPropertiesKt.getText

default final @NonNull AnnotatedString SemanticsPropertiesKt.getText(
    @NonNull SemanticsPropertyReceiver receiver
)

Text of the semantics node. It must be real text instead of developer-set content description.

See also
editableText

SemanticsPropertiesKt.getTextLayoutResult

default final void SemanticsPropertiesKt.getTextLayoutResult(
    @NonNull SemanticsPropertyReceiver receiver,
    String label,
    Function1<@NonNull List<@NonNull TextLayoutResult>, @NonNull Boolean> action
)

Action to get a Text/TextField node's TextLayoutResult. The result is the first element of layout (the argument of the AccessibilityAction).

Parameters
String label

Optional label for this action.

Function1<@NonNull List<@NonNull TextLayoutResult>, @NonNull Boolean> action

Action to be performed when the SemanticsActions.GetTextLayoutResult is called.

SemanticsPropertiesKt.getTextSelectionRange

default final @NonNull TextRange SemanticsPropertiesKt.getTextSelectionRange(
    @NonNull SemanticsPropertyReceiver receiver
)

Text selection range for the text field.

SemanticsPropertiesKt.getToggleableState

default final @NonNull ToggleableState SemanticsPropertiesKt.getToggleableState(
    @NonNull SemanticsPropertyReceiver receiver
)

The state of a toggleable component.

The presence of this property indicates that the element is toggleable.

SemanticsPropertiesKt.getTraversalIndex

default final float SemanticsPropertiesKt.getTraversalIndex(
    @NonNull SemanticsPropertyReceiver receiver
)

A value to manually control screenreader traversal order.

This API can be used to customize TalkBack traversal order. When the traversalIndex property is set on a traversalGroup or on a screenreader-focusable node, then the sorting algorithm will prioritize nodes with smaller traversalIndexs earlier. The default traversalIndex value is zero, and traversalIndices are compared at a peer level.

For example,traversalIndex = -1f can be used to force a top bar to be ordered earlier, and traversalIndex = 1f to make a bottom bar ordered last, in the edge cases where this does not happen by default. As another example, if you need to reorder two Buttons within a Row, then you can set isTraversalGroup = true on the Row, and set traversalIndex on one of the Buttons.

Note that if traversalIndex seems to have no effect, be sure to set isTraversalGroup = true as well.

SemanticsPropertiesKt.getVerticalScrollAxisRange

default final @NonNull ScrollAxisRange SemanticsPropertiesKt.getVerticalScrollAxisRange(
    @NonNull SemanticsPropertyReceiver receiver
)

The vertical scroll state of this node if this node is scrollable.

SemanticsPropertiesKt.heading

default final void SemanticsPropertiesKt.heading(
    @NonNull SemanticsPropertyReceiver receiver
)

The node is marked as heading for accessibility.

See also
Heading

SemanticsPropertiesKt.indexForKey

default final void SemanticsPropertiesKt.indexForKey(
    @NonNull SemanticsPropertyReceiver receiver,
    @NonNull Function1<@NonNull Object, @NonNull Integer> mapping
)

The index of an item identified by a given key. The key is usually defined during the creation of the container. If the key did not match any of the items' keys, the mapping must return -1.

SemanticsPropertiesKt.insertTextAtCursor

default final void SemanticsPropertiesKt.insertTextAtCursor(
    @NonNull SemanticsPropertyReceiver receiver,
    String label,
    Function1<@NonNull AnnotatedString, @NonNull Boolean> action
)

Action to insert text into this node at the current cursor position, or replacing the selection if text is selected.

Expected to be used on editable text fields.

Parameters
String label

Optional label for this action.

Function1<@NonNull AnnotatedString, @NonNull Boolean> action

Action to be performed when SemanticsActions.InsertTextAtCursor is called.

SemanticsPropertiesKt.invisibleToUser

@ExperimentalComposeUiApi
default final void SemanticsPropertiesKt.invisibleToUser(
    @NonNull SemanticsPropertyReceiver receiver
)

Whether this node is specially known to be invisible to the user.

For example, if the node is currently occluded by a dark semitransparent pane above it, then for all practical purposes the node is invisible to the user, but the system cannot automatically determine that. To make the screen reader linear navigation skip over this type of invisible node, this property can be set.

If looking for a way to hide semantics of small items from screen readers because they're redundant with semantics of their parent, consider SemanticsModifier.clearAndSetSemantics instead.

SemanticsPropertiesKt.isContainer

default final boolean SemanticsPropertiesKt.isContainer(
    @NonNull SemanticsPropertyReceiver receiver
)

Whether this semantics node is a container. This is defined as a node whose function is to serve as a boundary or border in organizing its children.

See also
IsContainer

SemanticsPropertiesKt.isTraversalGroup

default final boolean SemanticsPropertiesKt.isTraversalGroup(
    @NonNull SemanticsPropertyReceiver receiver
)

Whether this semantics node is a traversal group. This is defined as a node whose function is to serve as a boundary or border in organizing its children.

See also
IsTraversalGroup

SemanticsPropertiesKt.onClick

default final void SemanticsPropertiesKt.onClick(
    @NonNull SemanticsPropertyReceiver receiver,
    String label,
    Function0<@NonNull Boolean> action
)

Action to be performed when the node is clicked (single-tapped).

Parameters
String label

Optional label for this action.

Function0<@NonNull Boolean> action

Action to be performed when the SemanticsActions.OnClick is called.

SemanticsPropertiesKt.onLongClick

default final void SemanticsPropertiesKt.onLongClick(
    @NonNull SemanticsPropertyReceiver receiver,
    String label,
    Function0<@NonNull Boolean> action
)

Action to be performed when the node is long clicked (long-pressed).

Parameters
String label

Optional label for this action.

Function0<@NonNull Boolean> action

Action to be performed when the SemanticsActions.OnLongClick is called.

SemanticsPropertiesKt.pageDown

default final void SemanticsPropertiesKt.pageDown(
    @NonNull SemanticsPropertyReceiver receiver,
    String label,
    Function0<@NonNull Boolean> action
)

Action to page down.

Parameters
String label

Optional label for this action.

Function0<@NonNull Boolean> action

Action to be performed when the SemanticsActions.PageDown is called.

SemanticsPropertiesKt.pageLeft

default final void SemanticsPropertiesKt.pageLeft(
    @NonNull SemanticsPropertyReceiver receiver,
    String label,
    Function0<@NonNull Boolean> action
)

Action to page left.

Parameters
String label

Optional label for this action.

Function0<@NonNull Boolean> action

Action to be performed when the SemanticsActions.PageLeft is called.

SemanticsPropertiesKt.pageRight

default final void SemanticsPropertiesKt.pageRight(
    @NonNull SemanticsPropertyReceiver receiver,
    String label,
    Function0<@NonNull Boolean> action
)

Action to page right.

Parameters
String label

Optional label for this action.

Function0<@NonNull Boolean> action

Action to be performed when the SemanticsActions.PageRight is called.

SemanticsPropertiesKt.pageUp

default final void SemanticsPropertiesKt.pageUp(
    @NonNull SemanticsPropertyReceiver receiver,
    String label,
    Function0<@NonNull Boolean> action
)

Action to page up.

Parameters
String label

Optional label for this action.

Function0<@NonNull Boolean> action

Action to be performed when the SemanticsActions.PageUp is called.

SemanticsPropertiesKt.password

default final void SemanticsPropertiesKt.password(
    @NonNull SemanticsPropertyReceiver receiver
)

The node is marked as a password.

SemanticsPropertiesKt.pasteText

default final void SemanticsPropertiesKt.pasteText(
    @NonNull SemanticsPropertyReceiver receiver,
    String label,
    Function0<@NonNull Boolean> action
)

This function adds the SemanticsActions.PasteText to the SemanticsPropertyReceiver. Use it to indicate that element is open for accepting paste data from the clipboard. There is no need to check if the clipboard data available as this is done by the framework. For this action to be triggered, the element must also have the SemanticsProperties.Focused property set.

Parameters
String label

Optional label for this action.

Function0<@NonNull Boolean> action

Action to be performed when the SemanticsActions.PasteText is called.

See also
focused

SemanticsPropertiesKt.performImeAction

default final void SemanticsPropertiesKt.performImeAction(
    @NonNull SemanticsPropertyReceiver receiver,
    String label,
    Function0<@NonNull Boolean> action
)

Action to invoke the IME action handler configured on the node.

Expected to be used on editable text fields.

A node that specifies an action callback should also report what IME action it will perform via the imeAction property.

Parameters
String label

Optional label for this action.

Function0<@NonNull Boolean> action

Action to be performed when SemanticsActions.PerformImeAction is called.

SemanticsPropertiesKt.popup

default final void SemanticsPropertiesKt.popup(
    @NonNull SemanticsPropertyReceiver receiver
)

Whether this semantics node represents a Popup. Not to be confused with if this node is part of a Popup.

SemanticsPropertiesKt.requestFocus

default final void SemanticsPropertiesKt.requestFocus(
    @NonNull SemanticsPropertyReceiver receiver,
    String label,
    Function0<@NonNull Boolean> action
)

Action that gives input focus to this node.

Parameters
String label

Optional label for this action.

Function0<@NonNull Boolean> action

Action to be performed when the SemanticsActions.RequestFocus is called.

SemanticsPropertiesKt.scrollBy

default final void SemanticsPropertiesKt.scrollBy(
    @NonNull SemanticsPropertyReceiver receiver,
    String label,
    Function2<@NonNull Float, @NonNull Float, @NonNull Boolean> action
)

Action to scroll by a specified amount.

Expected to be used in conjunction with verticalScrollAxisRange/horizontalScrollAxisRange.

Parameters
String label

Optional label for this action.

Function2<@NonNull Float, @NonNull Float, @NonNull Boolean> action

Action to be performed when the SemanticsActions.ScrollBy is called.

SemanticsPropertiesKt.scrollToIndex

default final void SemanticsPropertiesKt.scrollToIndex(
    @NonNull SemanticsPropertyReceiver receiver,
    String label,
    @NonNull Function1<@NonNull Integer, @NonNull Boolean> action
)

Action to scroll a container to the index of one of its items.

The action should throw an IllegalArgumentException if the index is out of bounds.

SemanticsPropertiesKt.selectableGroup

default final void SemanticsPropertiesKt.selectableGroup(
    @NonNull SemanticsPropertyReceiver receiver
)

The node is marked as a collection of horizontally or vertically stacked selectable elements.

Unlike collectionInfo which marks a collection of any elements and asks developer to provide all the required information like number of elements etc., this semantics will populate the number of selectable elements automatically. Note that if you use this semantics with lazy collections, it won't get the number of elements in the collection.

See also
selected

SemanticsPropertiesKt.setCollectionInfo

default final void SemanticsPropertiesKt.setCollectionInfo(
    @NonNull SemanticsPropertyReceiver receiver,
    @NonNull CollectionInfo collectionInfo
)

This semantics marks node as a collection and provides the required information.

SemanticsPropertiesKt.setCollectionItemInfo

default final void SemanticsPropertiesKt.setCollectionItemInfo(
    @NonNull SemanticsPropertyReceiver receiver,
    @NonNull CollectionItemInfo collectionItemInfo
)

This semantics marks node as an items of a collection and provides the required information.

If you mark items of a collection, you should also be marking the collection with collectionInfo.

SemanticsPropertiesKt.setContainer

default final void SemanticsPropertiesKt.setContainer(
    @NonNull SemanticsPropertyReceiver receiver,
    boolean isContainer
)

Whether this semantics node is a container. This is defined as a node whose function is to serve as a boundary or border in organizing its children.

See also
IsContainer

SemanticsPropertiesKt.setContentDescription

default final void SemanticsPropertiesKt.setContentDescription(
    @NonNull SemanticsPropertyReceiver receiver,
    @NonNull String contentDescription
)

Developer-set content description of the semantics node.

If this is not set, accessibility services will present the text of this node as the content.

This typically should not be set directly by applications, because some screen readers will cease presenting other relevant information when this property is present. This is intended to be used via Foundation components which are inherently intractable to automatically describe, such as Image, Icon, and Canvas.

SemanticsPropertiesKt.setCustomActions

default final void SemanticsPropertiesKt.setCustomActions(
    @NonNull SemanticsPropertyReceiver receiver,
    @NonNull List<@NonNull CustomAccessibilityAction> customActions
)

Custom actions which are defined by app developers.

SemanticsPropertiesKt.setEditableText

default final void SemanticsPropertiesKt.setEditableText(
    @NonNull SemanticsPropertyReceiver receiver,
    @NonNull AnnotatedString editableText
)

Input text of the text field with visual transformation applied to it. It must be a real text entered by the user with visual transformation applied on top of the input text instead of a developer-set content description.

SemanticsPropertiesKt.setFocused

default final void SemanticsPropertiesKt.setFocused(
    @NonNull SemanticsPropertyReceiver receiver,
    boolean focused
)

Whether this semantics node is focused. The presence of this property indicates this node is focusable

See also
Focused

SemanticsPropertiesKt.setHorizontalScrollAxisRange

default final void SemanticsPropertiesKt.setHorizontalScrollAxisRange(
    @NonNull SemanticsPropertyReceiver receiver,
    @NonNull ScrollAxisRange horizontalScrollAxisRange
)

The horizontal scroll state of this node if this node is scrollable.

SemanticsPropertiesKt.setImeAction

default final void SemanticsPropertiesKt.setImeAction(
    @NonNull SemanticsPropertyReceiver receiver,
    @NonNull ImeAction imeAction
)

Contains the IME action provided by the node.

For example, "go to next form field" or "submit".

A node that specifies an action should also specify a callback to perform the action via performImeAction.

SemanticsPropertiesKt.setLiveRegion

default final void SemanticsPropertiesKt.setLiveRegion(
    @NonNull SemanticsPropertyReceiver receiver,
    @NonNull LiveRegionMode liveRegion
)

This node is marked as live region for accessibility. This indicates to accessibility services they should automatically notify the user about changes to the node's content description or text, or to the content descriptions or text of the node's children (where applicable). It should be used with caution, especially with assertive mode which immediately stops the current audio and the user does not hear the rest of the content. An example of proper use is a Snackbar which is marked as LiveRegionMode.Polite.

SemanticsPropertiesKt.setPaneTitle

default final void SemanticsPropertiesKt.setPaneTitle(
    @NonNull SemanticsPropertyReceiver receiver,
    @NonNull String paneTitle
)

Accessibility-friendly title for a screen's pane. For accessibility purposes, a pane is a visually distinct portion of a window, such as the contents of a open drawer. In order for accessibility services to understand a pane's window-like behavior, you should give descriptive titles to your app's panes. Accessibility services can then provide more granular information to users when a pane's appearance or content changes.

See also
PaneTitle

SemanticsPropertiesKt.setProgress

default final void SemanticsPropertiesKt.setProgress(
    @NonNull SemanticsPropertyReceiver receiver,
    String label,
    Function1<@NonNull Float, @NonNull Boolean> action
)

Action to set the current value of the progress bar.

Expected to be used in conjunction with progressBarRangeInfo.

Parameters
String label

Optional label for this action.

Function1<@NonNull Float, @NonNull Boolean> action

Action to be performed when the SemanticsActions.SetProgress is called.

SemanticsPropertiesKt.setProgressBarRangeInfo

default final void SemanticsPropertiesKt.setProgressBarRangeInfo(
    @NonNull SemanticsPropertyReceiver receiver,
    @NonNull ProgressBarRangeInfo progressBarRangeInfo
)

The semantics is represents a range of possible values with a current value. For example, when used on a slider control, this will allow screen readers to communicate the slider's state.

SemanticsPropertiesKt.setRole

default final void SemanticsPropertiesKt.setRole(
    @NonNull SemanticsPropertyReceiver receiver,
    @NonNull Role role
)

The type of user interface element. Accessibility services might use this to describe the element or do customizations. Most roles can be automatically resolved by the semantics properties of this element. But some elements with subtle differences need an exact role. If an exact role is not listed in Role, this property should not be set and the framework will automatically resolve it.

SemanticsPropertiesKt.setSelected

default final void SemanticsPropertiesKt.setSelected(
    @NonNull SemanticsPropertyReceiver receiver,
    boolean selected
)

Whether this element is selected (out of a list of possible selections).

The presence of this property indicates that the element is selectable.

SemanticsPropertiesKt.setSelection

default final void SemanticsPropertiesKt.setSelection(
    @NonNull SemanticsPropertyReceiver receiver,
    String label,
    Function3<@NonNull Integer, @NonNull Integer, @NonNull Boolean, @NonNull Boolean> action
)

Action to set text selection by character index range.

If this action is provided, the selection data must be provided using textSelectionRange.

Parameters
String label

Optional label for this action.

Function3<@NonNull Integer, @NonNull Integer, @NonNull Boolean, @NonNull Boolean> action

Action to be performed when the SemanticsActions.SetSelection is called. The parameters to the action are: startIndex, endIndex, and whether the indices are relative to the original text or the transformed text (when a VisualTransformation is applied).

SemanticsPropertiesKt.setStateDescription

default final void SemanticsPropertiesKt.setStateDescription(
    @NonNull SemanticsPropertyReceiver receiver,
    @NonNull String stateDescription
)

Developer-set state description of the semantics node.

For example: on/off. If this not set, accessibility services will derive the state from other semantics properties, like ProgressBarRangeInfo, but it is not guaranteed and the format will be decided by accessibility services.

SemanticsPropertiesKt.setTestTag

default final void SemanticsPropertiesKt.setTestTag(
    @NonNull SemanticsPropertyReceiver receiver,
    @NonNull String testTag
)

Test tag attached to this semantics node.

This can be used to find nodes in testing frameworks:

SemanticsPropertiesKt.setTestTagsAsResourceId

@ExperimentalComposeUiApi
default final void SemanticsPropertiesKt.setTestTagsAsResourceId(
    @NonNull SemanticsPropertyReceiver receiver,
    @ExperimentalComposeUiApi boolean testTagsAsResourceId
)

Configuration toggle to map testTags to resource-id.

This provides a way of filling in AccessibilityNodeInfo.viewIdResourceName, which in the View System is populated based on the resource string in the XML.

testTags are also provided in AccessibilityNodeInfo.extras under key "androidx.compose.ui.semantics.testTag". However, when using UIAutomator or on Android 7 and below, extras are not available, so a more backwards-compatible way of making testTags available to accessibility-tree-based integration tests is sometimes needed. resource-id was the most natural property to repurpose for this.

This property applies to a semantics subtree. For example, if it's set to true on the root semantics node of the app (and no child nodes set it back to false), then every testTag will be mapped.

SemanticsPropertiesKt.setText

default final void SemanticsPropertiesKt.setText(
    @NonNull SemanticsPropertyReceiver receiver,
    @NonNull AnnotatedString text
)

Text of the semantics node. It must be real text instead of developer-set content description.

See also
editableText

SemanticsPropertiesKt.setText

default final void SemanticsPropertiesKt.setText(
    @NonNull SemanticsPropertyReceiver receiver,
    String label,
    Function1<@NonNull AnnotatedString, @NonNull Boolean> action
)

Action to set the text contents of this node.

Expected to be used on editable text fields.

Parameters
String label

Optional label for this action.

Function1<@NonNull AnnotatedString, @NonNull Boolean> action

Action to be performed when SemanticsActions.SetText is called.

SemanticsPropertiesKt.setTextSelectionRange

default final void SemanticsPropertiesKt.setTextSelectionRange(
    @NonNull SemanticsPropertyReceiver receiver,
    @NonNull TextRange textSelectionRange
)

Text selection range for the text field.

SemanticsPropertiesKt.setToggleableState

default final void SemanticsPropertiesKt.setToggleableState(
    @NonNull SemanticsPropertyReceiver receiver,
    @NonNull ToggleableState toggleableState
)

The state of a toggleable component.

The presence of this property indicates that the element is toggleable.

SemanticsPropertiesKt.setTraversalGroup

default final void SemanticsPropertiesKt.setTraversalGroup(
    @NonNull SemanticsPropertyReceiver receiver,
    boolean isTraversalGroup
)

Whether this semantics node is a traversal group. This is defined as a node whose function is to serve as a boundary or border in organizing its children.

See also
IsTraversalGroup

SemanticsPropertiesKt.setTraversalIndex

default final void SemanticsPropertiesKt.setTraversalIndex(
    @NonNull SemanticsPropertyReceiver receiver,
    float traversalIndex
)

A value to manually control screenreader traversal order.

This API can be used to customize TalkBack traversal order. When the traversalIndex property is set on a traversalGroup or on a screenreader-focusable node, then the sorting algorithm will prioritize nodes with smaller traversalIndexs earlier. The default traversalIndex value is zero, and traversalIndices are compared at a peer level.

For example,traversalIndex = -1f can be used to force a top bar to be ordered earlier, and traversalIndex = 1f to make a bottom bar ordered last, in the edge cases where this does not happen by default. As another example, if you need to reorder two Buttons within a Row, then you can set isTraversalGroup = true on the Row, and set traversalIndex on one of the Buttons.

Note that if traversalIndex seems to have no effect, be sure to set isTraversalGroup = true as well.

SemanticsPropertiesKt.setVerticalScrollAxisRange

default final void SemanticsPropertiesKt.setVerticalScrollAxisRange(
    @NonNull SemanticsPropertyReceiver receiver,
    @NonNull ScrollAxisRange verticalScrollAxisRange
)

The vertical scroll state of this node if this node is scrollable.