New Compose Multiplatform components arrived on Composables UICheck it out →

Modifier in Wear Material Compose



Limits swipe to dismiss to be active from the edge of the viewport only. Used when the center of the screen needs to be able to handle horizontal paging, such as 2-d scrolling a Map or swiping horizontally between pages. Swipe to the right is intercepted on the left part of the viewport with width specified by [edgeWidth], with other touch events ignored - vertical scroll, click, long click, etc.

Currently Edge swipe, like swipe to dismiss, is only supported on the left part of the viewport regardless of layout direction as content is swiped away from left to right.

Requires that the element to which this modifier is applied exists within a SwipeToDismissBox which is using the same [SwipeToDismissBoxState] instance.

Last updated:


dependencies {


    "SwipeToDismiss has been migrated to " +
        "Please import Modifier.edgeSwipeToDismiss from instead.",
    replaceWith = ReplaceWith(
        "swipeToDismissBoxState, edgeWidth)"

fun Modifier.edgeSwipeToDismiss(
    swipeToDismissBoxState: SwipeToDismissBoxState,
    edgeWidth: Dp = SwipeToDismissBoxDefaults.EdgeWidth


swipeToDismissBoxStateA state of SwipeToDismissBox. Used to trigger swipe gestures on SwipeToDismissBox
edgeWidthA width of edge, where swipe should be recognised

Code Example


fun EdgeSwipeForSwipeToDismiss(
    navigateBack: () -> Unit
) {
    val state = rememberSwipeToDismissBoxState()

    // When using Modifier.edgeSwipeToDismiss, it is required that the element on which the
    // modifier applies exists within a SwipeToDismissBox which shares the same state.
        state = state,
        onDismissed = navigateBack
    ) { isBackground ->
        val horizontalScrollState = rememberScrollState(0)
        if (isBackground) {
                modifier = Modifier.fillMaxSize()
        } else {
            Box(modifier = Modifier.fillMaxSize()) {
                    modifier = Modifier.align(Alignment.Center)
                    text = "This text can be scrolled horizontally - to dismiss, swipe " +
                        "right from the left edge of the screen (called Edge Swiping)",