androidx.compose.material3
IconButton
Composable function
An icon button runs an action with just an icon. Use it in toolbars and lists, where text would take too much space.

IconButton(onClick = {}) {
Icon(Icons.Filled.Settings, contentDescription = "Settings")
}
The standard IconButton has no background. The others add a filled, tonal or outlined container. See Icon button types.

Row(horizontalArrangement = Arrangement.spacedBy(8.dp)) {
IconButton(onClick = {}) { Icon(Icons.Filled.Favorite, "Like") }
FilledIconButton(onClick = {}) { Icon(Icons.Filled.Favorite, "Like") }
FilledTonalIconButton(onClick = {}) { Icon(Icons.Filled.Favorite, "Like") }
OutlinedIconButton(onClick = {}) { Icon(Icons.Filled.Favorite, "Like") }
}
Basic
Takes one shape.
@Composable
fun IconButton(
onClick: () -> Unit,
modifier: Modifier = Modifier,
enabled: Boolean = true,
colors: IconButtonColors = IconButtonDefaults.iconButtonColors(),
interactionSource: MutableInteractionSource? = null,
shape: Shape = IconButtonDefaults.standardShape,
content: @Composable () -> Unit,
)
onClick: () -> UnitRequired
onClick: () -> UnitRequiredCalled when the button is clicked.
modifier: ModifierOptional
modifier: ModifierOptionalDefault: Modifier
Changes size, padding, or position of the button. See the Modifier guide.
Expressive has five sizes. Set one with Modifier.size(IconButtonDefaults.mediumContainerSize()), and the icon size with IconButtonDefaults.mediumIconSize.

Row(horizontalArrangement = Arrangement.spacedBy(8.dp), verticalAlignment = Alignment.CenterVertically) {
FilledIconButton(onClick = {}, modifier = Modifier.size(IconButtonDefaults.smallContainerSize())) {
Icon(Icons.Filled.Favorite, "Like", Modifier.size(IconButtonDefaults.smallIconSize))
}
FilledIconButton(onClick = {}, modifier = Modifier.size(IconButtonDefaults.mediumContainerSize())) {
Icon(Icons.Filled.Favorite, "Like", Modifier.size(IconButtonDefaults.mediumIconSize))
}
FilledIconButton(onClick = {}, modifier = Modifier.size(IconButtonDefaults.largeContainerSize())) {
Icon(Icons.Filled.Favorite, "Like", Modifier.size(IconButtonDefaults.largeIconSize))
}
}
enabled: BooleanOptional
enabled: BooleanOptionalDefault: true
Set to false to make the button gray and not clickable.

FilledIconButton(onClick = {}, enabled = false) {
Icon(Icons.Filled.Favorite, contentDescription = "Like")
}
colors: IconButtonColorsOptional
colors: IconButtonColorsOptionalDefault: IconButtonDefaults.iconButtonColors()
Sets the container and icon colors, for both enabled and disabled.
Each type has its own function in IconButtonDefaults, for example filledIconButtonColors().

FilledIconButton(
onClick = {},
colors = IconButtonDefaults.filledIconButtonColors(
containerColor = MaterialTheme.colorScheme.tertiary,
contentColor = MaterialTheme.colorScheme.onTertiary,
),
) {
Icon(Icons.Filled.Favorite, contentDescription = "Like")
}
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. IconButtonDefaults has round and square presets for each size, like smallSquareShape.

FilledIconButton(onClick = {}, shape = IconButtonDefaults.smallSquareShape) {
Icon(Icons.Filled.Favorite, contentDescription = "Like")
}
content: @Composable () -> UnitRequired
content: @Composable () -> UnitRequiredThe icon. Always set a contentDescription on the Icon, so screen readers can say what the button does.
Expressive
Takes shapes: one shape at rest and one while pressed.
@Composable
fun IconButton(
onClick: () -> Unit,
shapes: IconButtonShapes,
modifier: Modifier = Modifier,
enabled: Boolean = true,
colors: IconButtonColors = IconButtonDefaults.iconButtonColors(),
interactionSource: MutableInteractionSource? = null,
content: @Composable () -> Unit,
)
shapes: IconButtonShapesRequiredSince 1.10
shapes: IconButtonShapesRequiredSince 1.10Sets two shapes: one at rest and one while pressed. Make one with IconButtonDefaults.shapes.

FilledIconButton(onClick = {}, shapes = IconButtonDefaults.shapes()) {
Icon(Icons.Filled.Favorite, contentDescription = "Like")
}
Same as above: onClick, modifier, enabled, colors, interactionSource, content.
Icon button types
See also
IconButtonDefaults: default values and helper functions forIconButton.