Segmented button

A row of two to five options for choosing one or several of them.

When to use

Segmented buttons help people select options, switch views or sort elements. Use single choice when exactly one option applies and multi choice when any number can be active.

Material 3 Expressive recommends connected button groups for new designs. The segmented button remains available and is not deprecated.

Playground

The interactive page has a playground with live property controls for this component and generated code.

Examples

Single choice

val options = listOf("Day", "Week", "Month")
var selected by rememberSaveable { mutableIntStateOf(0) }

SingleChoiceSegmentedButtonRow {
    options.forEachIndexed { index, label ->
        SegmentedButton(
            selected = selected == index,
            onClick = { selected = index },
            shape = SegmentedButtonDefaults.itemShape(index, options.size),
        ) {
            Text(label)
        }
    }
}

Multiple choice

val options = listOf("Bold", "Italic", "Underline")
var checked by remember { mutableStateOf(setOf<Int>()) }

MultiChoiceSegmentedButtonRow {
    options.forEachIndexed { index, label ->
        SegmentedButton(
            checked = index in checked,
            onCheckedChange = { isChecked ->
                checked = if (isChecked) checked + index else checked - index
            },
            shape = SegmentedButtonDefaults.itemShape(index, options.size),
        ) {
            Text(label)
        }
    }
}

Parameters

NameTypeDefaultDescription
selected / checkedBooleanWhether the segment is active.
shapeShapeUse SegmentedButtonDefaults.itemShape(index, count).
icon@Composable () -> UnitSegmentedButtonDefaults.Icon(selected)Leading icon, by default a check mark when selected.
colorsSegmentedButtonColorsSegmentedButtonDefaults.colors()Colors per state.

Guidelines

Do:

Don't:

Accessibility

Related components