State of Compose 2023 results are in! Click here to learn more

← Back to Wear Material

SwipeToRevealCard

Component
in
Wear Material
. Since 1.3.0-alpha06

Overview

Code Examples

SwipeToReveal Material composable for Cards. This adds the option to configure up to two additional actions on the Card: a mandatory primaryAction and an optional secondaryAction. These actions are initially hidden and revealed only when the content is swiped. These additional actions can be triggered by clicking on them after they are revealed. primaryAction can also be triggered by performing a full swipe of the content.

For actions like "Delete", consider adding undoPrimaryAction (displayed when the primaryAction is activated) and/or undoSecondaryAction (displayed when the secondaryAction is activated). Adding undo composables allow users to undo the action that they just performed.

Example of SwipeToRevealCard with primary and secondary actions

Overloads

SwipeToRevealCard

@ExperimentalWearMaterialApi
@OptIn(ExperimentalWearFoundationApi::class)
@Composable
public fun SwipeToRevealCard(
    primaryAction: SwipeToRevealAction,
    revealState: RevealState,
    modifier: Modifier = Modifier,
    secondaryAction: SwipeToRevealAction? = null,
    undoPrimaryAction: SwipeToRevealAction? = null,
    undoSecondaryAction: SwipeToRevealAction? = null,
    colors: SwipeToRevealActionColors = SwipeToRevealDefaults.actionColors(),
    shape: Shape = SwipeToRevealDefaults.CardActionShape,
    content: @Composable () -> Unit
)

Parameters

NameDescription
primaryActionA SwipeToRevealAction instance to describe the primary action when swiping. See SwipeToRevealDefaults.primaryAction. The action will be triggered on click or a full swipe.
revealStateRevealState of the SwipeToReveal
modifierModifier to be applied on the composable
secondaryActionA SwipeToRevealAction instance to describe the contents of secondary action. See SwipeToRevealDefaults.secondaryAction. The action will be triggered on clicking the action.
undoPrimaryActionA SwipeToRevealAction instance to describe the contents of undo action when the primary action was triggered. See SwipeToRevealDefaults.undoAction.
undoSecondaryActionSwipeToRevealAction instance to describe the contents of undo action when secondary action was triggered. See SwipeToRevealDefaults.undoAction.
colorsAn instance of SwipeToRevealActionColors to describe the colors of actions. See SwipeToRevealDefaults.actionColors.
shapeThe shape of primary and secondary action composables. Recommended shape for cards is SwipeToRevealDefaults.CardActionShape.
contentThe initial content shown prior to the swipe-to-reveal gesture. @see SwipeToReveal