Accessibility action - Jetpack Compose

In Jetpack Compose, you can add custom actions for assistive technologies using the customActions property inside the semantics block modifier.

// add custom action
Button(
    onClick = { /* Your click handler */ },
    modifier = Modifier
        .wrapContentSize()
        .semantics {
            customActions = listOf(
                // your custom action
                CustomAccessibilityAction(label = "Add bookmark") {
                    // Bookmark logic
                    true
                }
            )
        }
) {
    Text("Bookmark button")
}

Furthermore, there are several ways to override labels for default actions. For Composables that expose the onClick parameter, specify the label inside the semantics block modifier. The SemanticsActions object provides a list of all predefined accessibility actions.

// override label for button
val buttonClickHandler: () -> Unit = { /* Your click handler */ }
Button(
    onClick = buttonClickHandler,
    modifier = Modifier
        .semantics {
            onClick(label = "Add bookmark") {
                buttonClickHandler.invoke()
                true
            }
        }
) {
    // Button content
}