androidx.compose.material3
ButtonGroupSince 1.10
Composable function
A button group is a row of related buttons. There are two kinds:
- Standard: separate buttons. When one is pressed, it grows and its neighbors shrink a little. Use
ButtonGroup. - Connected: joined buttons where one option is picked, like a segmented button. Use a
RowofToggleButtons with connected shapes.

val options = listOf("Day", "Week", "Month")
var selected by remember { mutableIntStateOf(0) }
Row(horizontalArrangement = Arrangement.spacedBy(ButtonGroupDefaults.ConnectedSpaceBetween)) {
options.forEachIndexed { index, label ->
ToggleButton(
checked = selected == index,
onCheckedChange = { selected = index },
shapes = when (index) {
0 -> ButtonGroupDefaults.connectedLeadingButtonShapes()
options.lastIndex -> ButtonGroupDefaults.connectedTrailingButtonShapes()
else -> ButtonGroupDefaults.connectedMiddleButtonShapes()
},
) { Text(label) }
}
}
For a connected group, give each button the shape for its position from ButtonGroupDefaults: connectedLeadingButtonShapes() for the first, connectedMiddleButtonShapes() for the middle ones, and connectedTrailingButtonShapes() for the last. Use ButtonGroupDefaults.ConnectedSpaceBetween as the gap.
ButtonGroup takes items, not composables. Add them with clickableItem and toggleableItem. Items that don't fit move into an overflow menu.

var bold by remember { mutableStateOf(true) }
var italic by remember { mutableStateOf(false) }
ButtonGroup(
overflowIndicator = { menuState -> ButtonGroupDefaults.OverflowIndicator(menuState) },
) {
toggleableItem(checked = bold, onCheckedChange = { bold = it }, label = "Bold")
toggleableItem(checked = italic, onCheckedChange = { italic = it }, label = "Italic")
clickableItem(onClick = {}, label = "Clear")
clickableItem(onClick = {}, label = "Font")
clickableItem(onClick = {}, label = "Size")
}
Parameters
@Composable
fun ButtonGroup(
overflowIndicator: @Composable (ButtonGroupMenuState) -> Unit,
modifier: Modifier = Modifier,
expandedRatio: Float = ButtonGroupDefaults.ExpandedRatio,
horizontalArrangement: Arrangement.Horizontal = ButtonGroupDefaults.HorizontalArrangement,
verticalAlignment: Alignment.Vertical = Alignment.Top,
content: ButtonGroupScope.() -> Unit,
)
overflowIndicator: @Composable (ButtonGroupMenuState) -> UnitRequired
overflowIndicator: @Composable (ButtonGroupMenuState) -> UnitRequiredThe button that opens the menu of items that don't fit. Use ButtonGroupDefaults.OverflowIndicator(menuState).
modifier: ModifierOptional
modifier: ModifierOptionalDefault: Modifier
Changes size, padding, or position. The width decides how many items fit.
expandedRatio: FloatOptional
expandedRatio: FloatOptionalDefault: ButtonGroupDefaults.ExpandedRatio
How much a pressed button grows, as a part of its width. Default: 0.15 (15 %).
horizontalArrangement: Arrangement.HorizontalOptional
horizontalArrangement: Arrangement.HorizontalOptionalDefault: ButtonGroupDefaults.HorizontalArrangement
Space between the buttons.
verticalAlignment: Alignment.VerticalOptionalSince 1.11
verticalAlignment: Alignment.VerticalOptionalSince 1.11Default: Alignment.Top
How buttons of different heights line up.
content: ButtonGroupScope.() -> UnitRequired
content: ButtonGroupScope.() -> UnitRequiredThe items. Add them with clickableItem(onClick, label), toggleableItem(checked, label, onCheckedChange), or customItem for anything else.
See also
ButtonGroupDefaults: default values and helper functions forButtonGroup.