Compose Modifier

appendTextContextMenuComponents

Adds a builder to be run when the text context menu is shown within this hierarchy.

AppendComponentsToTextContextMenu

@Sampled
@Composable
fun AppendComponentsToTextContextMenu() {
    val textFieldState = rememberTextFieldState()
    BasicTextField(
        state = textFieldState,
        modifier =
            Modifier.appendTextContextMenuComponents {
                separator()
                item(key = ClearKeyDataObject, label = "Clear") {
                    textFieldState.clearText()
                    close()
                }
                separator()
            },
    )
}
Jetpack Compose beyond MaterialFree components, screens and templates for apps that don’t look like Google’s. Copy them into your app, or let your coding agent add them.Browse for free

Content updated: