Compose SwipeToDismiss threshold is ignored and executed action when user lift finger

2 weeks ago 7
ARTICLE AD BOX

I am implementing SwipeToDismissBox using Jetpack Compose Material 3. I have two specific requirements:

Custom Threshold: The swipe action should be triggered when the user drags more than 25% of the width.

Action Timing: The function (onRemove and onArchive) must not execute immediately when the threshold is crossed. Instead, it should wait until the user lifts their finger, the "dismiss" animation completes, and the background is fully revealed.

Currently, despite setting positionalThreshold to 0.25f, the currentValue does not change (and thus my LaunchedEffect doesn't trigger) until I drag at least 50% of the width. The custom threshold seems to be ignored.

Additionally, I am unsure how to correctly handle the animation-to-action flow. Attempting to call swipeToDismissBoxState.dismiss() does the animation but then the function (onRemove or onArchive) is not executed.

val thresholdPercent = 0.25f val swipeToDismissBoxState = rememberSwipeToDismissBoxState( positionalThreshold = { it * thresholdPercent }, ) LaunchedEffect(swipeToDismissBoxState.currentValue) { println("SwipeToDismissBoxValue progress: ${swipeToDismissBoxState.progress}") when (swipeToDismissBoxState.currentValue) { SwipeToDismissBoxValue.EndToStart -> { swipeToDismissBoxState.dismiss(SwipeToDismissBoxValue.EndToStart) onRemove() swipeToDismissBoxState.snapTo(SwipeToDismissBoxValue.Settled) } SwipeToDismissBoxValue.StartToEnd -> { swipeToDismissBoxState.dismiss(SwipeToDismissBoxValue.StartToEnd) onArchive() swipeToDismissBoxState.snapTo(SwipeToDismissBoxValue.Settled) } SwipeToDismissBoxValue.Settled -> {} } } SwipeToDismissBox( state = swipeToDismissBoxState, backgroundContent = {...} }

I don't use the parameter onConfirmValue of rememberSwipeToDismissState because it's deprecated (my library version is: composeBom = "2025.10.01")

Read Entire Article