---
title: "action"
description: "Create an [Action] that runs [block] when triggered."
type: "composable"
---

<div class='type'>Composable Function</div>


<a id='references'></a>

<div class='sourceset sourceset-android'>Android</div>


```kotlin
@Composable
public fun action(key: String? = null, block: () -> Unit): Action
```


Create an `Action` that runs `block` when triggered.

#### Parameters

| | |
| --- | --- |
| key | A stable and unique key that identifies this action. This key is saved in the PendingIntent for the UI element, and used to trigger this action when the element is clicked. If not provided we use `currentCompositeKeyHash` as the key. Since that key is based on the location within the composition, it will be identical for lambdas generated in a loop (if not using `androidx.compose.runtime.key`). To avoid this, prefer setting explicit keys for your lambdas. |
| block | the function to be run when this action is triggered. |





