---
title: "appendTextContextMenuComponents"
description: "Adds a [builder] to be run when the text context menu is shown within this hierarchy.

When there are multiple instances of this modifier in a layout hierarchy, the [builder]s are
applied in order from bottom to top. They are then filtered by every
[Modifier.filterTextContextMenuComponents][filterTextContextMenuComponents] in the hierarchy."
type: "modifier"
---

<div class='type'>Compose Modifier</div>

<a id='references'></a>
<div class='sourceset sourceset-common'>Common</div>


```kotlin
fun Modifier.appendTextContextMenuComponents(
    builder: TextContextMenuBuilderScope.() -> Unit
): Modifier
```


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

When there are multiple instances of this modifier in a layout hierarchy, the `builder`s are
applied in order from bottom to top. They are then filtered by every
`Modifier.filterTextContextMenuComponents` in the hierarchy.

#### Parameters

| | |
| --- | --- |
| builder | a snapshot-aware builder function for adding components to the context menu. In this function you can use member functions from the receiver `TextContextMenuBuilderScope`, such as `separator()`, to add components. The `item` function is not in the common source set, but is instead defined as an extension function in the platform specific source sets. |




## Code Examples
### AppendComponentsToTextContextMenu
```kotlin
@Composable
fun AppendComponentsToTextContextMenu() {
    val textFieldState = rememberTextFieldState()
    BasicTextField(
        state = textFieldState,
        modifier =
            Modifier.appendTextContextMenuComponents {
                separator()
                item(key = ClearKeyDataObject, label = "Clear") {
                    textFieldState.clearText()
                    close()
                }
                separator()
            },
    )
}
```

