Composables UI is out: our new component library for Compose Multiplatform ->
Compose Component

ButtonGroup

A layout composable that places its children in a horizontal sequence.

ButtonGroup social preview

ButtonGroup

Source set: Common
@Composable
fun ButtonGroup(
    overflowIndicator: @Composable (ButtonGroupMenuState) -> Unit,
    modifier: Modifier = Modifier,
    @FloatRange(0.0) expandedRatio: Float = ButtonGroupDefaults.ExpandedRatio,
    horizontalArrangement: Arrangement.Horizontal = ButtonGroupDefaults.HorizontalArrangement,
    verticalAlignment: Alignment.Vertical = Alignment.Top,
    content: ButtonGroupScope.() -> Unit,
)

Parameters

overflowIndicator composable that is displayed at the end of the button group if it needs to overflow. It receives a ButtonGroupMenuState.
modifier the Modifier to be applied to the button group.
expandedRatio the percentage, represented by a float, of the width of the interacted child element that will be used to expand the interacted child element as well as compress the neighboring children. By Default, standard button group will expand the interacted child element by ButtonGroupDefaults.ExpandedRatio of its width and this will be propagated to its neighbors. If 0f is passed into this slot, then the interacted child element will not expand at all and the neighboring elements will not compress. If 1f is passed into this slot, then the interacted child element will expand to 200% of its default width when pressed.
horizontalArrangement The horizontal arrangement of the button group's children.
verticalAlignment The vertical alignment of the button group's children.
content the content displayed in the button group, expected to use a composable that i s tagged with ButtonGroupScope.animateWidth.

Last updated: