# Toggle button groups **Note:** Segmented buttons are being deprecated in the Material 3 expressive update. For those who have updated, use the [connected button group](https://github.com/material-components/material-components-android/tree/master/docs/components/ButtonGroup.md) instead, which has mostly the same functionality but with an updated visual design. [Toggle button group (Segmented buttons)](https://m3.material.io/components/segmented-buttons) can be used to select from a group of choices. There are two types of toggle buttons that can be placed in a toggle button group: * [Toggle button](#toggle-button) * [Icon toggle button](#icon-toggle-button) **Note:** Images use various dynamic color schemes. ## Design & API documentation * [Material 3 (M3) spec](https://m3.material.io/components/segmented-buttons) * [API reference](https://developer.android.com/reference/com/google/android/material/button/package-summary) ## Anatomy A toggle button has a shared stroked container, icons and/or text labels. ![Toggle button group anatomy](assets/buttons/togglebuttongroup-anatomy.png) 1. Container 2. Icon (optional for unselected state) 3. Label text More details on anatomy items in the [component guidelines](https://m3.material.io/components/segmented-buttons/guidelines#75ec9219-0196-4c59-bd6a-ed9a1b481013). ## M3 Expressive ### M3 Expressive update The segmented button is being deprecated. Use the [connected button group](https://github.com/material-components/material-components-android/tree/master/docs/components/ButtonGroup.md) instead. [More on M3 Expressive](https://m3.material.io/blog/building-with-m3-expressive) ### M3 Expressive style Default style in the expressive themes: `Widget.Material3Expressive.MaterialButtonToggleGroup` ## Key properties ### Selection attributes Element | Attribute | Related method(s) | Default value ------------------------------------- | ----------------------- | ------------------------------------------------ | ------------- **Single selection** | `app:singleSelection` | `setSingleSelection`
`isSingleSelection` | `false` **Selection required** | `app:selectionRequired` | `setSelectionRequired`
`isSelectionRequired` | `false` **Enable the group and all children** | `android:enabled` | `setEnabled`
`isEnabled` | `true` ### Container attributes Element | Attribute | Related method(s) | Default value ------------------------------- | --------------------- | --------------------------------------------- | ------------- **Size of inner corners** | `app:innerCornerSize` | `setInnerCornerSize`
`getInnerCornerSize` | `0dp` **Spacing between buttons** | `android:spacing` | `setSpacing`
`getSpacing` | `0dp` **Group shape (outer corners)** | `app:shapeAppearance` | `setShapeAppearance`
`getShapeAppearance` | `none` ### Styles Element | Style | Theme attribute ----------------- | -------------------------------------------- | --------------- **Default style** | `Widget.Material3.MaterialButtonToggleGroup` | `?attr/materialButtonToggleGroupStyle` See the full list of [styles](https://github.com/material-components/material-components-android/tree/master/lib/java/com/google/android/material/button/res/values/styles.xml) and [attrs](https://github.com/material-components/material-components-android/tree/master/lib/java/com/google/android/material/button/res/values/attrs.xml). ## Code implementation Before you can use Material buttons, you need to add a dependency to the Material components for Android library. For more information, go to the [Getting started](https://github.com/material-components/material-components-android/tree/master/docs/getting-started.md) page. **Note:** `