SwipeToDismiss

fun SwipeToDismiss(onDelete: () -> Unit, modifier: Modifier = Modifier, content: @Composable () -> Unit)

A composable that allows swiping from end to start to dismiss an item.

This component provides:

  • End-to-start swipe only: Prevents accidental dismissal from start-to-end

  • Visual feedback: Shows delete icon with error container background color during swipe

  • Animated background: Background color animates based on swipe progress

  • Confirmation: onDelete is only called when swipe completes the threshold

Common use cases include:

  • Dismissing items in a LazyColumn list

  • Removing notifications

  • Deleting messages or emails

Usage example:

LazyColumn {
items(items) { item ->
SwipeToDismiss(
onDelete = { viewModel.deleteItem(item.id) },
) {
ItemCard(item = item)
}
}
}

Parameters

onDelete

The callback to be invoked when the item is swiped to dismiss.

modifier

The modifier to be applied to the composable.

content

The content to be displayed (the item being dismissed).