Jetpack Compose Tag Chip

Jetpack Compose Material

1.2.0 introduced Chip composable

Chip(    modifier = Modifier.padding(2.dp),    onClick = {  },    leadingIcon = {        Icon(Icons.Filled.Star, tint = Color.Yellow, contentDescription = "Cover")    }) {    Text("Star")}

Custom

@Composablefun Chip(modifier: Modifier = Modifier, text: String, maxLines: Int = 1, maxWidth: Dp = 100.dp) {    Surface(        modifier = modifier,        elevation = 8.dp,        shape = RoundedCornerShape(8.dp)    ) {        Text(            modifier = Modifier.padding(2.dp).widthIn(0.dp, maxWidth),            maxLines = maxLines,            text = text,            overflow = TextOverflow.Ellipsis        )    }}

❤️ Is this article helpful?

Buy me a coffee ☕ or support my work via PayPal to keep this space 🖖 and ad-free.

Do send some 💖 to @d_luaz or share this article.

✨ By Desmond Lua

A dream boy who enjoys making apps, travelling and making youtube videos. Follow me on @d_luaz

👶 Apps I built

Travelopy - discover travel places in Malaysia, Singapore, Taiwan, Japan.