---
title: "ToggleButton"
description: "Wear Material `ToggleButton` that offers a single slot to take any content (text, icon or image)."
type: "component"
---

<div class='type'>Composable Component</div>



Wear Material `ToggleButton` that offers a single slot to take any content (text, icon or image).

<a id='references'></a>

<div class='sourceset sourceset-android'>Android</div>


> **Deprecated** This overload is provided for backwards compatibility with Compose for Wear OS 1.0.A newer overload is available with an additional shape parameter.

```kotlin
@Composable
public fun ToggleButton(
    checked: Boolean,
    onCheckedChange: (Boolean) -> Unit,
    modifier: Modifier = Modifier,
    enabled: Boolean = true,
    colors: ToggleButtonColors = ToggleButtonDefaults.toggleButtonColors(),
    interactionSource: MutableInteractionSource = remember { MutableInteractionSource() },
    content: @Composable BoxScope.() -> Unit,
): Unit
```


#### Parameters

| | |
| --- | --- |
| checked | Boolean flag indicating whether this toggle button is currently checked. |
| onCheckedChange | Callback to be invoked when this toggle button is clicked. |
| modifier | Modifier to be applied to the toggle button. |
| enabled | Controls the enabled state of the toggle button. When `false`, this toggle button will not be clickable. |
| colors | `ToggleButtonColors` that will be used to resolve the background and content color for this toggle button. See `ToggleButtonDefaults.toggleButtonColors`. |
| interactionSource | The `MutableInteractionSource` representing the stream of `Interaction`s for this toggle button. You can create and pass in your own remembered `MutableInteractionSource` if you want to observe `Interaction`s and customize the appearance / behavior of this ToggleButton in different `Interaction`s. |
| content | The icon, image or text to be drawn inside the toggle button. |




<div class='sourceset sourceset-android'>Android</div>


> **Deprecated** This overload is provided for backwards compatibility with Compose for Wear OS 1.1.A newer overload is available with an additional semantic role parameter.

```kotlin
@Composable
public fun ToggleButton(
    checked: Boolean,
    onCheckedChange: (Boolean) -> Unit,
    modifier: Modifier = Modifier,
    enabled: Boolean = true,
    colors: ToggleButtonColors = ToggleButtonDefaults.toggleButtonColors(),
    interactionSource: MutableInteractionSource = remember { MutableInteractionSource() },
    shape: Shape = CircleShape,
    content: @Composable BoxScope.() -> Unit,
): Unit
```


#### Parameters

| | |
| --- | --- |
| checked | Boolean flag indicating whether this toggle button is currently checked. |
| onCheckedChange | Callback to be invoked when this toggle button is clicked. |
| modifier | Modifier to be applied to the toggle button. |
| enabled | Controls the enabled state of the toggle button. When `false`, this toggle button will not be clickable. |
| colors | `ToggleButtonColors` that will be used to resolve the background and content color for this toggle button. See `ToggleButtonDefaults.toggleButtonColors`. |
| interactionSource | The `MutableInteractionSource` representing the stream of `Interaction`s for this toggle button. You can create and pass in your own remembered `MutableInteractionSource` if you want to observe `Interaction`s and customize the appearance / behavior of this ToggleButton in different `Interaction`s. |
| shape | Defines the shape for this toggle button. It is strongly recommended to use the default as this shape is a key characteristic of the Wear Material Theme. |
| content | The icon, image or text to be drawn inside the toggle button. |




<div class='sourceset sourceset-android'>Android</div>


```kotlin
@Composable
public fun ToggleButton(
    checked: Boolean,
    onCheckedChange: (Boolean) -> Unit,
    modifier: Modifier = Modifier,
    enabled: Boolean = true,
    colors: ToggleButtonColors = ToggleButtonDefaults.toggleButtonColors(),
    interactionSource: MutableInteractionSource? = null,
    shape: Shape = CircleShape,
    role: Role = ToggleButtonDefaults.DefaultRole,
    content: @Composable BoxScope.() -> Unit,
)
```


#### Parameters

| | |
| --- | --- |
| checked | Boolean flag indicating whether this toggle button is currently checked. |
| onCheckedChange | Callback to be invoked when this toggle button is clicked. |
| modifier | Modifier to be applied to the toggle button. |
| enabled | Controls the enabled state of the toggle button. When `false`, this toggle button will not be clickable. |
| colors | `ToggleButtonColors` that will be used to resolve the background and content color for this toggle button. See `ToggleButtonDefaults.toggleButtonColors`. |
| interactionSource | an optional hoisted `MutableInteractionSource` for observing and emitting `Interaction`s for this toggle button. You can use this to change the toggle button's appearance or preview the toggle button in different states. Note that if `null` is provided, interactions will still happen internally. |
| shape | Defines the shape for this toggle button. It is strongly recommended to use the default as this shape is a key characteristic of the Wear Material Theme. |
| role | Role semantics that accessibility services can use to provide more context to users. |
| content | The icon, image or text to be drawn inside the toggle button. |






## Code Examples
### ToggleButtonWithIcon
```kotlin
@Composable
fun ToggleButtonWithIcon() {
    var checked by remember { mutableStateOf(true) }
    ToggleButton(checked = checked, onCheckedChange = { checked = it }, enabled = true) {
        Icon(
            painter = painterResource(id = R.drawable.ic_airplanemode_active_24px),
            contentDescription = "airplane",
            modifier =
                Modifier.size(ToggleButtonDefaults.DefaultIconSize)
                    .wrapContentSize(align = Alignment.Center),
        )
    }
}
```

