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

← Back to Material 3 Compose

SwipeToDismissBox

Component
in
Material 3
. Since 1.2.0-alpha11

Overview

Code Examples

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

Overloads

SwipeToDismissBox

@Composable
@ExperimentalMaterial3Api
fun SwipeToDismissBox(
    state: DismissState,
    backgroundContent: @Composable RowScope.() -> Unit,
    modifier: Modifier = Modifier,
    directions: Set<DismissDirection> = setOf(EndToStart, StartToEnd),
    content: @Composable RowScope.() -> Unit,
)

Parameters

NameDescription
stateThe state of this component.
backgroundContentA 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.
contentThe content that can be dismissed.
modifierOptional Modifier for this component.
directionsThe set of directions in which the component can be dismissed