How to implement a Connected Button Group in Jetpack Compose Material 3?


I would like to add a gender selection input to my application's form. The first component that came to mind was SingleChoiceSegmentedButtonRow, so I checked its documentation.

There, I found the following message (August 3, 2026):

Segmented buttons not supported

I followed the link to the Button groups page.

However, I am having trouble finding the relevant documentation for this component. The page redirects me to the list of all Material 3 components instead of the documentation for button groups.

Could someone point me to the correct documentation or provide an example implementation of a single-choice input using a Connected Button Group?

0
Aug 3 at 12:21 PM
User AvatarStanisław Olszak
#android#android-jetpack-compose

Accepted Answer

@Composable
fun GenderSelector() {
    val options = listOf("Male", "Female", "Other")
    var selectedIndex by rememberSaveable { mutableIntStateOf(0) }

    SingleChoiceSegmentedButtonRow {
        options.forEachIndexed { index, label ->
            SegmentedButton(
                selected = selectedIndex == index,
                onClick = { selectedIndex = index },
                shape = SegmentedButtonDefaults.itemShape(
                    index = index,
                    count = options.size
                ),
                label = {
                    Text(label)
                }
            )
        }
    }
}
User AvatarSuraj Bahadur
Aug 3 at 4:50 PM
1