IconButton

Functions summary

Unit
@Composable
IconButton(
    onClick: () -> Unit,
    modifier: Modifier,
    enabled: Boolean,
    interactionSource: MutableInteractionSource?,
    content: @Composable () -> Unit
)

IconButton is a clickable icon, used to represent actions.

Cmn

Functions

IconButton

@Composable
fun IconButton(
    onClick: () -> Unit,
    modifier: Modifier = Modifier,
    enabled: Boolean = true,
    interactionSource: MutableInteractionSource? = null,
    content: @Composable () -> Unit
): Unit

IconButton is a clickable icon, used to represent actions. An IconButton has an overall minimum touch target size of 48 x 48dp, to meet accessibility guidelines. content is centered inside the IconButton.

This component is typically used inside an App Bar for the navigation icon / actions. See App Bar documentation for samples of this.

content should typically be an Icon, using an icon from androidx.compose.material.internal.Icons. If using a custom icon, note that the typical size for the internal icon is 24 x 24 dp.

import androidx.compose.material.Icon
import androidx.compose.material.IconButton
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Favorite

IconButton(onClick = { /* doSomething() */ }) {
    Icon(Icons.Filled.Favorite, contentDescription = "Localized description")
}
Parameters
onClick: () -> Unit

the lambda to be invoked when this icon is pressed

modifier: Modifier = Modifier

optional Modifier for this IconButton

enabled: Boolean = true

whether or not this IconButton will handle input events and appear enabled for semantics purposes

interactionSource: MutableInteractionSource? = null

an optional hoisted MutableInteractionSource for observing and emitting Interactions for this IconButton. You can use this to change the IconButton's appearance or preview the IconButton in different states. Note that if null is provided, interactions will still happen internally.

content: @Composable () -> Unit

the content (icon) to be drawn inside the IconButton. This is typically an Icon.