androidx.compose.material3
SingleChoiceSegmentedButtonRow
Composable function
A segmented button is a row of joined buttons. Use it to switch views or pick options, with two to five choices.
SingleChoiceSegmentedButtonRow: one option at a time, like radio buttons.MultiChoiceSegmentedButtonRow: any number of options, like checkboxes.
Inside the row, add one SegmentedButton per option. SegmentedButton only exists inside a row.

val options = listOf("Day", "Week", "Month")
var selected by remember { mutableIntStateOf(1) }
SingleChoiceSegmentedButtonRow {
options.forEachIndexed { index, label ->
SegmentedButton(
selected = index == selected,
onClick = { selected = index },
shape = SegmentedButtonDefaults.itemShape(index = index, count = options.size),
) { Text(label) }
}
}

val options = listOf("Walk", "Bike", "Car")
val checked = remember { mutableStateListOf(true, false, true) }
MultiChoiceSegmentedButtonRow {
options.forEachIndexed { index, label ->
SegmentedButton(
checked = checked[index],
onCheckedChange = { checked[index] = it },
shape = SegmentedButtonDefaults.itemShape(index = index, count = options.size),
) { Text(label) }
}
}
Parameters
@Composable
fun SingleChoiceSegmentedButtonRow(
modifier: Modifier = Modifier,
space: Dp = SegmentedButtonDefaults.BorderWidth,
content: @Composable SingleChoiceSegmentedButtonRowScope.() -> Unit,
)
modifier: ModifierOptional
modifier: ModifierOptionalDefault: Modifier
Changes size, padding, or position. See the Modifier guide.
space: DpOptional
space: DpOptionalDefault: SegmentedButtonDefaults.BorderWidth
The overlap between buttons, so their borders join. Default: one border width.
content: @Composable SingleChoiceSegmentedButtonRowScope.() -> UnitRequired
content: @Composable SingleChoiceSegmentedButtonRowScope.() -> UnitRequiredThe buttons. Add one SegmentedButton per option.
Rows and buttons
SingleChoiceSegmentedButtonRowMultiChoiceSegmentedButtonRowSegmentedButton