Compose Component

Chip

Base level Wear Material Chip that offers a single slot to take any content.

ChipWithIconAndLabel

@Sampled
@Composable
fun ChipWithIconAndLabel() {
    Chip(
        onClick = { /* Do something */ },
        enabled = true,
        // Primary label can have up to 3 lines of text
        label = {
            Text(
                text = "Main label can span up to 3 lines",
                maxLines = 3,
                overflow = TextOverflow.Ellipsis,
            )
        },
        icon = {
            Icon(
                painter = painterResource(id = R.drawable.ic_airplanemode_active_24px),
                contentDescription = "airplane",
                modifier =
                    Modifier.size(ChipDefaults.IconSize).wrapContentSize(align = Alignment.Center),
            )
        },
    )
}

ChipWithIconAndLabels

@Sampled
@Composable
fun ChipWithIconAndLabels() {
    Chip(
        onClick = { /* Do something */ },
        enabled = true,
        // Primary label has maximum 3 lines, Secondary label has maximum 2 lines.
        label = { Text(text = "Main label", maxLines = 3, overflow = TextOverflow.Ellipsis) },
        secondaryLabel = {
            Text(text = "secondary label", maxLines = 2, overflow = TextOverflow.Ellipsis)
        },
        icon = {
            Icon(
                painter = painterResource(id = R.drawable.ic_airplanemode_active_24px),
                contentDescription = "airplane",
                modifier =
                    Modifier.size(ChipDefaults.IconSize).wrapContentSize(align = Alignment.Center),
            )
        },
    )
}
Jetpack Compose beyond MaterialFree components, screens and templates for apps that don’t look like Google’s. Copy them into your app, or let your coding agent add them.Browse for free

Content updated: