androidx.compose.material3

Icon

Composable function

Icon draws a small image in one color. By default it is 24 dp and takes the color of the surrounding component, so an icon inside a button gets the button's text color.

Icons with and without a tint
Icons with and without a tint
Row(horizontalArrangement = Arrangement.spacedBy(16.dp)) {
    Icon(Icons.Filled.Star, contentDescription = "Favorite")
    Icon(Icons.Filled.Star, contentDescription = null, tint = MaterialTheme.colorScheme.primary)
    Icon(Icons.Filled.Star, contentDescription = null, modifier = Modifier.size(40.dp))
}

Material icons are in the Icons object, for example Icons.Filled.Star. The basic set comes with material-icons-core. For your own icons, use a vector resource and painterResource().

Vector

Takes an ImageVector, like Icons.Filled.Star.

@Composable
fun Icon(
    imageVector: ImageVector,
    contentDescription: String?,
    modifier: Modifier = Modifier,
    tint: Color = LocalContentColor.current,
)

imageVector: ImageVectorRequired

The icon, for example Icons.Filled.Star.

contentDescription: String?Required

What the icon means, for screen readers. Like "Delete" or "Settings". Pass null when the icon is only decoration, or when a text next to it already says the same.

modifier: ModifierOptional

Default: Modifier

Changes size, padding, or position of the icon. Set the size with Modifier.size(...).

tint: ColorOptional

Default: LocalContentColor.current

The color. Default: LocalContentColor, the color of the surrounding component. Pass Color.Unspecified to draw the image in its own colors.

Bitmap

Takes an ImageBitmap.

@Composable
fun Icon(
    bitmap: ImageBitmap,
    contentDescription: String?,
    modifier: Modifier = Modifier,
    tint: Color = LocalContentColor.current,
)

bitmap: ImageBitmapRequired

The icon as a bitmap image.

Same as above: contentDescription, modifier, tint.

Painter

Takes a Painter, for example from a resource file.

@Composable
fun Icon(
    painter: Painter,
    contentDescription: String?,
    modifier: Modifier = Modifier,
    tint: Color = LocalContentColor.current,
)

painter: PainterRequired

The icon as a Painter, for example painterResource(Res.drawable.my_icon).

Same as above: contentDescription, modifier, tint.

Painter, changing tint

Takes tint as a function, for colors that animate often.

@Composable
fun Icon(
    painter: Painter,
    tint: ColorProducer?,
    contentDescription: String?,
    modifier: Modifier = Modifier,
)

tint: ColorProducer?Required

The color. Default: LocalContentColor, the color of the surrounding component. Pass Color.Unspecified to draw the image in its own colors.

Same as above: painter, contentDescription, modifier.