# SwipeToRevealScope

Artifact: [androidx.wear.compose:compose-material3](https://developer.android.com/jetpack/androidx/releases/wear-compose) [View Source](https://cs.android.com/search?q=file:androidx/wear/compose/material3/SwipeToReveal.kt+class:androidx.wear.compose.material3.SwipeToRevealScope) Added in [1.5.0](https://developer.android.com/jetpack/androidx/releases/wear-compose#1.5.0)


```
class SwipeToRevealScope
```

<br />

*** ** * ** ***

Scope for the actions of a `https://developer.android.com/reference/kotlin/androidx/wear/compose/material3/SwipeToReveal.composable#SwipeToReveal(kotlin.Function1,kotlin.Function0,androidx.wear.compose.material3.SurfaceTransformation,androidx.compose.ui.Modifier,kotlin.Function1,kotlin.Function1,kotlin.Function1,androidx.wear.compose.material3.RevealState,androidx.wear.compose.material3.RevealDirection,kotlin.Boolean,androidx.wear.compose.foundation.GestureInclusion,androidx.compose.ui.unit.Dp,kotlin.Function0)` composable. Used to define the primary, secondary, undo primary and undo secondary actions.

## Summary

| ### Public functions |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `@https://developer.android.com/reference/kotlin/androidx/compose/runtime/Composable https://developer.android.com/reference/kotlin/androidx/wear/compose/material3/SwipeToRevealScope#PrimaryActionButton(kotlin.Function0,kotlin.Function0,kotlin.Function0,androidx.compose.ui.Modifier,androidx.compose.ui.graphics.Color,androidx.compose.ui.graphics.Color)( onClick: () -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html, icon: @https://developer.android.com/reference/kotlin/androidx/compose/runtime/Composable () -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html, text: @https://developer.android.com/reference/kotlin/androidx/compose/runtime/Composable () -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html, modifier: https://developer.android.com/reference/kotlin/androidx/compose/ui/Modifier, containerColor: https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color, contentColor: https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color )` Provides a button for the primary action of a `https://developer.android.com/reference/kotlin/androidx/wear/compose/material3/SwipeToReveal.composable#SwipeToReveal(kotlin.Function1,kotlin.Function0,androidx.wear.compose.material3.SurfaceTransformation,androidx.compose.ui.Modifier,kotlin.Function1,kotlin.Function1,kotlin.Function1,androidx.wear.compose.material3.RevealState,androidx.wear.compose.material3.RevealDirection,kotlin.Boolean,androidx.wear.compose.foundation.GestureInclusion,androidx.compose.ui.unit.Dp,kotlin.Function0)`. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `@https://developer.android.com/reference/kotlin/androidx/compose/runtime/Composable https://developer.android.com/reference/kotlin/androidx/wear/compose/material3/SwipeToRevealScope#SecondaryActionButton(kotlin.Function0,kotlin.Function0,androidx.compose.ui.Modifier,androidx.compose.ui.graphics.Color,androidx.compose.ui.graphics.Color)( onClick: () -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html, icon: @https://developer.android.com/reference/kotlin/androidx/compose/runtime/Composable () -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html, modifier: https://developer.android.com/reference/kotlin/androidx/compose/ui/Modifier, containerColor: https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color, contentColor: https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color )` Provides a button for the optional secondary action of a `https://developer.android.com/reference/kotlin/androidx/wear/compose/material3/SwipeToReveal.composable#SwipeToReveal(kotlin.Function1,kotlin.Function0,androidx.wear.compose.material3.SurfaceTransformation,androidx.compose.ui.Modifier,kotlin.Function1,kotlin.Function1,kotlin.Function1,androidx.wear.compose.material3.RevealState,androidx.wear.compose.material3.RevealDirection,kotlin.Boolean,androidx.wear.compose.foundation.GestureInclusion,androidx.compose.ui.unit.Dp,kotlin.Function0)`. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `@https://developer.android.com/reference/kotlin/androidx/compose/runtime/Composable https://developer.android.com/reference/kotlin/androidx/wear/compose/material3/SwipeToRevealScope#UndoActionButton(kotlin.Function0,kotlin.Function0,androidx.compose.ui.Modifier,kotlin.Function0,androidx.compose.ui.graphics.Color,androidx.compose.ui.graphics.Color)( onClick: () -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html, text: @https://developer.android.com/reference/kotlin/androidx/compose/runtime/Composable () -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html, modifier: https://developer.android.com/reference/kotlin/androidx/compose/ui/Modifier, icon: (@https://developer.android.com/reference/kotlin/androidx/compose/runtime/Composable () -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)?, containerColor: https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color, contentColor: https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color )` Provides a button for the undo action of a `https://developer.android.com/reference/kotlin/androidx/wear/compose/material3/SwipeToReveal.composable#SwipeToReveal(kotlin.Function1,kotlin.Function0,androidx.wear.compose.material3.SurfaceTransformation,androidx.compose.ui.Modifier,kotlin.Function1,kotlin.Function1,kotlin.Function1,androidx.wear.compose.material3.RevealState,androidx.wear.compose.material3.RevealDirection,kotlin.Boolean,androidx.wear.compose.foundation.GestureInclusion,androidx.compose.ui.unit.Dp,kotlin.Function0)`. |

## Public functions

### PrimaryActionButton

Added in [1.6.0](https://developer.android.com/jetpack/androidx/releases/wear-compose#1.6.0)

```
@Composable
fun PrimaryActionButton(
    onClick: () -> Unit,
    icon: @Composable () -> Unit,
    text: @Composable () -> Unit,
    modifier: Modifier = Modifier,
    containerColor: Color = Color.Unspecified,
    contentColor: Color = Color.Unspecified
): Unit
```

Provides a button for the primary action of a `https://developer.android.com/reference/kotlin/androidx/wear/compose/material3/SwipeToReveal.composable#SwipeToReveal(kotlin.Function1,kotlin.Function0,androidx.wear.compose.material3.SurfaceTransformation,androidx.compose.ui.Modifier,kotlin.Function1,kotlin.Function1,kotlin.Function1,androidx.wear.compose.material3.RevealState,androidx.wear.compose.material3.RevealDirection,kotlin.Boolean,androidx.wear.compose.foundation.GestureInclusion,androidx.compose.ui.unit.Dp,kotlin.Function0)`.

When first revealed the primary action displays an icon and then, if fully swiped, it additionally shows text. By default the button height is `https://developer.android.com/reference/kotlin/androidx/wear/compose/material3/ButtonDefaults#Height()` - it is recommended to set the button height to `https://developer.android.com/reference/kotlin/androidx/wear/compose/material3/SwipeToRevealDefaults#LargeActionButtonHeight()` for large content items like `https://developer.android.com/reference/kotlin/androidx/wear/compose/material3/Card.composable#Card(kotlin.Function0,androidx.compose.ui.Modifier,kotlin.Function0,kotlin.String,kotlin.Boolean,androidx.compose.ui.graphics.Shape,androidx.wear.compose.material3.CardColors,androidx.compose.foundation.BorderStroke,androidx.compose.foundation.layout.PaddingValues,androidx.compose.foundation.interaction.MutableInteractionSource,androidx.wear.compose.material3.SurfaceTransformation,kotlin.Function1)`s, using `https://developer.android.com/reference/kotlin/androidx/compose/foundation/layout/height.modifier#(androidx.compose.ui.Modifier).height(androidx.compose.foundation.layout.IntrinsicSize)`.

| Parameters |
|---|---|
| `onClick: () -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | Callback to be executed when the action is performed via a button click. |
| `icon: @https://developer.android.com/reference/kotlin/androidx/compose/runtime/Composable () -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | Icon composable to be displayed for this action. |
| `text: @https://developer.android.com/reference/kotlin/androidx/compose/runtime/Composable () -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | Text composable to be displayed when the user fully swipes to execute the primary action. |
| `modifier: https://developer.android.com/reference/kotlin/androidx/compose/ui/Modifier = Modifier` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/Modifier` to be applied on the composable. |
| `containerColor: https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color = Color.Unspecified` | Container color for this action. This can be `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color#Unspecified()`, and in case it is, a default color will be used. |
| `contentColor: https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color = Color.Unspecified` | Content color for this action. This can be `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color#Unspecified()`, and in case it is, a default color will be used. |

### SecondaryActionButton

Added in [1.6.0](https://developer.android.com/jetpack/androidx/releases/wear-compose#1.6.0)

```
@Composable
fun SecondaryActionButton(
    onClick: () -> Unit,
    icon: @Composable () -> Unit,
    modifier: Modifier = Modifier,
    containerColor: Color = Color.Unspecified,
    contentColor: Color = Color.Unspecified
): Unit
```

Provides a button for the optional secondary action of a `https://developer.android.com/reference/kotlin/androidx/wear/compose/material3/SwipeToReveal.composable#SwipeToReveal(kotlin.Function1,kotlin.Function0,androidx.wear.compose.material3.SurfaceTransformation,androidx.compose.ui.Modifier,kotlin.Function1,kotlin.Function1,kotlin.Function1,androidx.wear.compose.material3.RevealState,androidx.wear.compose.material3.RevealDirection,kotlin.Boolean,androidx.wear.compose.foundation.GestureInclusion,androidx.compose.ui.unit.Dp,kotlin.Function0)`.

Secondary action only displays an icon, because, unlike the primary action, it is never extended to full width so does not have room to display text. By default, the button height is `https://developer.android.com/reference/kotlin/androidx/wear/compose/material3/ButtonDefaults#Height()` - it is recommended to set the button height to `https://developer.android.com/reference/kotlin/androidx/wear/compose/material3/SwipeToRevealDefaults#LargeActionButtonHeight()` for large content items like `https://developer.android.com/reference/kotlin/androidx/wear/compose/material3/Card.composable#Card(kotlin.Function0,androidx.compose.ui.Modifier,kotlin.Function0,kotlin.String,kotlin.Boolean,androidx.compose.ui.graphics.Shape,androidx.wear.compose.material3.CardColors,androidx.compose.foundation.BorderStroke,androidx.compose.foundation.layout.PaddingValues,androidx.compose.foundation.interaction.MutableInteractionSource,androidx.wear.compose.material3.SurfaceTransformation,kotlin.Function1)`s, using `https://developer.android.com/reference/kotlin/androidx/compose/foundation/layout/height.modifier#(androidx.compose.ui.Modifier).height(androidx.compose.foundation.layout.IntrinsicSize)`.

| Parameters |
|---|---|
| `onClick: () -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | Callback to be executed when the action is performed via a button click. |
| `icon: @https://developer.android.com/reference/kotlin/androidx/compose/runtime/Composable () -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | Icon composable to be displayed for this action. |
| `modifier: https://developer.android.com/reference/kotlin/androidx/compose/ui/Modifier = Modifier` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/Modifier` to be applied on the composable. |
| `containerColor: https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color = Color.Unspecified` | Container color for this action. This can be `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color#Unspecified()`, and in case it is, a default color will be used. |
| `contentColor: https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color = Color.Unspecified` | Content color for this action. This can be `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color#Unspecified()`, and in case it is, a default color will be used. |

### UndoActionButton

Added in [1.6.0](https://developer.android.com/jetpack/androidx/releases/wear-compose#1.6.0)

```
@Composable
fun UndoActionButton(
    onClick: () -> Unit,
    text: @Composable () -> Unit,
    modifier: Modifier = Modifier,
    icon: (@Composable () -> Unit)? = null,
    containerColor: Color = Color.Unspecified,
    contentColor: Color = Color.Unspecified
): Unit
```

Provides a button for the undo action of a `https://developer.android.com/reference/kotlin/androidx/wear/compose/material3/SwipeToReveal.composable#SwipeToReveal(kotlin.Function1,kotlin.Function0,androidx.wear.compose.material3.SurfaceTransformation,androidx.compose.ui.Modifier,kotlin.Function1,kotlin.Function1,kotlin.Function1,androidx.wear.compose.material3.RevealState,androidx.wear.compose.material3.RevealDirection,kotlin.Boolean,androidx.wear.compose.foundation.GestureInclusion,androidx.compose.ui.unit.Dp,kotlin.Function0)`. When the user performs either the primary or secondary action, and the corresponding undo action is provided, the initial action will be hidden once `https://developer.android.com/reference/kotlin/androidx/wear/compose/material3/SwipeToReveal.composable#SwipeToReveal(kotlin.Function1,kotlin.Function0,androidx.wear.compose.material3.SurfaceTransformation,androidx.compose.ui.Modifier,kotlin.Function1,kotlin.Function1,kotlin.Function1,androidx.wear.compose.material3.RevealState,androidx.wear.compose.material3.RevealDirection,kotlin.Boolean,androidx.wear.compose.foundation.GestureInclusion,androidx.compose.ui.unit.Dp,kotlin.Function0)` has animated to the fully revealed state, and the undo action button will be displayed.

It is recommended to always use the default undo button height, `https://developer.android.com/reference/kotlin/androidx/wear/compose/material3/ButtonDefaults#Height()`.

| Parameters |
|---|---|
| `onClick: () -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | Callback to be executed when the action is performed via a button click. |
| `text: @https://developer.android.com/reference/kotlin/androidx/compose/runtime/Composable () -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | Text composable to indicate what the undo action is, to be displayed when the user executes the primary action. |
| `modifier: https://developer.android.com/reference/kotlin/androidx/compose/ui/Modifier = Modifier` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/Modifier` to be applied on the composable. |
| `icon: (@https://developer.android.com/reference/kotlin/androidx/compose/runtime/Composable () -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)? = null` | Optional Icon composable to be displayed for this action. |
| `containerColor: https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color = Color.Unspecified` | Container color for this action. This can be `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color#Unspecified()`, and in case it is, a default color will be used. |
| `contentColor: https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color = Color.Unspecified` | Content color for this action. This can be `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color#Unspecified()`, and in case it is, a default color will be used. |