androidx.compose.material3
IconToggleButton
Composable function
An icon toggle button is an IconButton that stays on or off, like a favorite or bookmark button.
The button does not remember its state. You keep it in a variable and update it in onCheckedChange.
To show the state, you can also change the icon, for example from an outlined to a filled heart.

var on by remember { mutableStateOf(true) }
Row(horizontalArrangement = Arrangement.spacedBy(8.dp)) {
IconToggleButton(checked = on, onCheckedChange = { on = it }) { Icon(Icons.Filled.Favorite, "Like") }
FilledIconToggleButton(checked = on, onCheckedChange = { on = it }) { Icon(Icons.Filled.Favorite, "Like") }
FilledTonalIconToggleButton(checked = on, onCheckedChange = { on = it }) { Icon(Icons.Filled.Favorite, "Like") }
OutlinedIconToggleButton(checked = on, onCheckedChange = { on = it }) { Icon(Icons.Filled.Favorite, "Like") }
}
Basic
Takes one shape.
@Composable
fun IconToggleButton(
checked: Boolean,
onCheckedChange: (Boolean) -> Unit,
modifier: Modifier = Modifier,
enabled: Boolean = true,
colors: IconToggleButtonColors = IconButtonDefaults.iconToggleButtonColors(),
interactionSource: MutableInteractionSource? = null,
shape: Shape = IconButtonDefaults.standardShape,
content: @Composable () -> Unit,
)
checked: BooleanRequired
checked: BooleanRequiredWhether the button is on. Pass your state here.
onCheckedChange: (Boolean) -> UnitRequired
onCheckedChange: (Boolean) -> UnitRequiredCalled with the new value when the button is clicked. Update your state here.
modifier: ModifierOptional
modifier: ModifierOptionalDefault: Modifier
Changes size, padding, or position. See the Modifier guide.
enabled: BooleanOptional
enabled: BooleanOptionalDefault: true
Set to false to make the button gray and not clickable.
colors: IconToggleButtonColorsOptional
colors: IconToggleButtonColorsOptionalDefault: IconButtonDefaults.iconToggleButtonColors()
Sets colors for on, off and disabled. Make one with IconButtonDefaults.iconToggleButtonColors. Each type has its own function.
interactionSource: MutableInteractionSource?Optional
interactionSource: MutableInteractionSource?OptionalDefault: null
Lets you observe or control press, hover and focus states. Leave it null unless your code must react to them. See InteractionSource.
shape: ShapeOptionalSince 1.9
shape: ShapeOptionalSince 1.9Default: IconButtonDefaults.standardShape
Sets the outline. Default: round.
content: @Composable () -> UnitRequired
content: @Composable () -> UnitRequiredThe icon. Set a contentDescription on the Icon.
Expressive
Takes shapes: separate shapes for rest, pressed and checked.
@Composable
fun IconToggleButton(
checked: Boolean,
onCheckedChange: (Boolean) -> Unit,
shapes: IconToggleButtonShapes,
modifier: Modifier = Modifier,
enabled: Boolean = true,
colors: IconToggleButtonColors = IconButtonDefaults.iconToggleButtonVibrantColors(),
interactionSource: MutableInteractionSource? = null,
content: @Composable () -> Unit,
)
shapes: IconToggleButtonShapesRequiredSince 1.10
shapes: IconToggleButtonShapesRequiredSince 1.10Sets shapes for rest, pressed and checked. Make one with IconButtonDefaults.toggleableShapes.
Same as above: checked, onCheckedChange, modifier, enabled, colors, interactionSource, content.