[ Web Proxy ]
URL:
Viewing: https://developer.android.com/develop/ui/compose/components/segmented-button [Back]  [Original]

Segmented button  |  Jetpack Compose  |  Android Developers Skip to main content
Essentials Design & Plan Develop Google Play Blog
Search:
Android Studio
Android Developers [Android Developers]

Segmented button Stay organized with collections Save and categorize content based on your preferences.

Use a segmented button to let users choose from a set of options, side-by-side. There are two types of segmented buttons:

A segmented button component is shown. The first button allows a single selection, while the second button allows multiple selections. [A segmented button component is shown. The first button allows a single selection, while the second button allows multiple selections.] Figure 1. A single-select button (1) and a multi-select button (2).

API surface

Use the SingleChoiceSegmentedButtonRow and MultiChoiceSegmentedButtonRow layouts to create segmented buttons. These layouts position and size SegmentedButtons correctly, and share the following key parameters:

Create a single-select segmented button

This example shows how to create a single-select segmented button:

@Composable
fun SingleChoiceSegmentedButton(modifier: Modifier = Modifier) {
    var selectedIndex by remember { mutableIntStateOf(0) }
    val options = listOf("Day", "Month", "Week")

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

Key points about the code

Result

A segmented button component with the options Day, Month, and Week is displayed. The Day option is currently selected. [A segmented button component with the options Day, Month, and Week is displayed. The Day option is currently selected.] Figure 2. A single-select button with one option picked.

Create a multi-select segmented button

This example shows how to create a multi-choice segmented button with icons that lets users select multiple options:

@Composable
fun MultiChoiceSegmentedButton(modifier: Modifier = Modifier) {
    val selectedOptions = remember {
        mutableStateListOf(false, false, false)
    }
    val options = listOf("Walk", "Ride", "Drive")

    MultiChoiceSegmentedButtonRow {
        options.forEachIndexed { index, label ->
            SegmentedButton(
                shape = SegmentedButtonDefaults.itemShape(
                    index = index,
                    count = options.size
                ),
                checked = selectedOptions[index],
                onCheckedChange = {
                    selectedOptions[index] = !selectedOptions[index]
                },
                icon = { SegmentedButtonDefaults.Icon(selectedOptions[index]) },
                label = {
                    when (label) {
                        "Walk" -> Icon(
                            imageVector =
                            Icons.AutoMirrored.Filled.DirectionsWalk,
                            contentDescription = "Directions Walk"
                        )
                        "Ride" -> Icon(
                            imageVector =
                            Icons.Default.DirectionsBus,
                            contentDescription = "Directions Bus"
                        )
                        "Drive" -> Icon(
                            imageVector =
                            Icons.Default.DirectionsCar,
                            contentDescription = "Directions Car"
                        )
                    }
                }
            )
        }
    }
}

Key points about the code

Result

A segmented button component with the options Walk, Ride, and Drive is shown. The Walk and Ride options are currently selected. [A segmented button component with the options Walk, Ride, and Drive is shown. The Walk and Ride options are currently selected.] Figure 3. A multi-select segmented button with two options picked.

Additional resources

Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.

Last updated 2026-08-14 UTC.

[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2026-08-14 UTC."],[],[]]

Web Proxy Viewer  |  New URL  |  Original Page