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

← Back to Material Compose

SwipeToDismiss

Component
in
Material
. Since 0.1.0-dev17

Overview

Code Examples

A composable that can be dismissed by swiping left or right.

Overloads

SwipeToDismiss

@Composable
@ExperimentalMaterialApi
fun SwipeToDismiss(
    state: DismissState,
    modifier: Modifier = Modifier,
    directions: Set<DismissDirection> = setOf(EndToStart, StartToEnd),
    dismissThresholds: (DismissDirection) -> ThresholdConfig = {
        FixedThreshold(DISMISS_THRESHOLD)
    },
    background: @Composable RowScope.() -> Unit,
    dismissContent: @Composable RowScope.() -> Unit
)

Parameters

NameDescription
stateThe state of this component.
modifierOptional Modifier for this component.
directionsThe set of directions in which the component can be dismissed.
dismissThresholdsThe thresholds the item needs to be swiped in order to be dismissed.
backgroundA composable that is stacked behind the content and is exposed when the content is swiped. You can/should use the state to have different backgrounds on each side.
dismissContentThe content that can be dismissed