AnimatedSpacingRow

fun AnimatedSpacingRow(spacing: Dp, modifier: Modifier = Modifier, verticalAlignment: Alignment.Vertical = Alignment.Top, animation: AnimatedSpacingRowAnimation = AnimatedSpacingRowAnimation(), content: @Composable AnimatedSpacingRowScope.() -> Unit)

Places children horizontally and animates both a child's occupied width and its surrounding spacing when the child is emitted by AnimatedSpacingRowScope.AnimatedVisibility.

Unlike androidx.compose.foundation.layout.Row, spacing is derived from the visibility progress of adjacent children. This keeps the gap on both sides of an entering or leaving child visually symmetric. The animation is driven by the same progress that collapses the child. Child-specific vertical alignment, baselines, alignment lines, and RowScope.weight retain their usual scope semantics. When a weighted animated child disappears, its released allocation is progressively redistributed among the other visible weighted children. Placement follows layout direction, including RTL order.

This layout is eager and is not a replacement for a lazy list. It supports one fixed, non-negative spacing value rather than the complete set of stock Arrangement.Horizontal strategies. Only children wrapped in AnimatedSpacingRowScope.AnimatedVisibility participate in animated spacing, and the visibility wrapper overlays multiple direct content children at the same origin. Intrinsic measurement is not specialized. Prefer the stock androidx.compose.foundation.layout.Row when its spacing does not need to participate in visibility transitions.

Parameters

spacing

fixed distance between fully visible adjacent children. It must not be negative.

modifier

modifier applied to the layout.

verticalAlignment

default vertical alignment for children that do not provide a scope-specific alignment.

animation

default visibility-animation configuration inherited by animated children.

content

children placed by the row. Use AnimatedSpacingRowScope.AnimatedVisibility for children whose occupied width and adjacent spacing should animate.