SwipeToRevealCard

Composable Component

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. It is recommended to trigger primaryAction on full swipe of the content.

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

Parameters

primaryActionA composable to describe the primary action when swiping. The action will be triggered on clicking the action. See SwipeToRevealPrimaryAction.
revealStateRevealState of the SwipeToReveal
onFullSwipeA lambda which will be triggered on full swipe from either of the anchors. We recommend to keep this similar to primary action click action. This sets the RevealState.lastActionType to RevealActionType.PrimaryAction.
modifierModifier to be applied on the composable
secondaryActionA composable to describe the contents of secondary action.The action will be triggered on clicking the action. See SwipeToRevealSecondaryAction
undoPrimaryActionA composable to describe the contents of undo action when the primary action was triggered. See SwipeToRevealUndoAction
undoSecondaryActionA composable to describe the contents of undo action when secondary action was triggered. See SwipeToRevealUndoAction
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. Custom accessibility actions should always be added to the content using Modifier.semantics - examples are shown in the code samples.