Icon composable is a convenient way to draw a single color icon on screen
that follows Material Design guidelines. To use
the Compose Material library (or the Compose Material 3 library).
For example, if you had a vector drawable that you wanted to load up with
Material defaults, you can use the
Icon composable as follows:
Icon( painter = painterResource(R.drawable.baseline_directions_bus_24), contentDescription = stringResource(id = R.string.bus_content_description) )
By default, the
Icon composable is tinted with
24.dp in size. It also exposes a
tint color parameter (which leverages
the same mechanism for tinting as described in the Image tint section).
Icon composable is intended for use for small icon elements. You
should use the
Image composable for more customization options.
The Material Icon library also includes a set of predefined
can be used in Compose without needing to import an SVG manually. To draw the
rounded version of the shopping cart
Icon( Icons.Rounded.ShoppingCart, contentDescription = stringResource(id = R.string.shopping_cart_content_desc) )
It's worth noting that it's not required to use
Icon to render a
VectorDrawable on screen, under the hood,
Modifier.paint(painterResource(R.drawable.ic_bus_stop)) to draw the
screen. For more information on all the available icons, take a look at the