Extra
SwipeToDismiss
A FormaUI swipe-to-dismiss row — lets the user swipe a row horizontally to dismiss it (e.g. delete or archive), delegating to Material 3's stable SwipeToDismissBox with hoisted state, a revealed background slot, and per-direction enable flags.
import dev.formaui.components.swipedismiss.FormaSwipeToDismiss
Preview
This toggle is site chrome only — the preview has its own light/dark switch inside.
Live preview — ~37 MB development build
Usage
val state = rememberSwipeToDismissBoxState()FormaSwipeToDismiss( state = state, onDismiss = { direction -> onRemove(item) }, backgroundContent = { Box( Modifier.fillMaxSize() .background(MaterialTheme.colorScheme.errorContainer) .padding(horizontal = FormaTheme.spacing.md), contentAlignment = Alignment.CenterEnd, ) { Text("Delete", color = MaterialTheme.colorScheme.onErrorContainer) } },) { FormaListItem(headline = item.title, supporting = item.subtitle)}
FormaSwipeToDismiss
Wraps RowScope content with a horizontal swipe-to-dismiss gesture; the caller creates the state via rememberSwipeToDismissBoxState and reacts to a completed swipe via onDismiss (or by reading state.dismissDirection). The backgroundContent slot is revealed behind the content while swiping — vary it per direction using state.
Supporting API
- rememberSwipeToDismissBoxStatefunction (Material 3)
- The component defines no state type of its own — callers create and own the swipe state via Material 3's rememberSwipeToDismissBoxState and read dismissDirection / currentValue from it.
- SwipeToDismissBoxValueenum (Material 3)
- The swipe direction reported to onDismiss and held by the state: StartToEnd, EndToStart, Settled.
Accessibility
Inherits Material 3's SwipeToDismissBox gesture handling; because a swipe gesture is not reachable by all users, pair the swipe action with an equivalent explicit control (e.g. a trailing overflow action) so the dismiss action stays operable without gestures.