Skip to content

Drag To Dismiss

Used for easily implementing the drag to dismiss pattern for media.

@Composable
fun ParentLayout() {
    Child(
        modifier = Modifier
            .dragToDismiss(
                state = dragToDismissState,
                dragThresholdCheck = { offset, _ ->
                    offset.getDistanceSquared() > with(density) {
                        240.dp.toPx().let { it * it }
                    }
                },
                onDismissed = {
                    ...
                },
            )
    )
    ...
}
Composable
Drag To Dismiss color drag to dismiss image drag to dismiss video drag to dismiss