Member-only story

Suggestion Chips in Jetpack Compose

Jayant Kumar🇮🇳
3 min readOct 2, 2022

--

Link For Non-Members

Hello everyone , hope you all are doing good. So in this article we will see what is suggestion chips & how we can create with jetpack compose😍.

Basically suggestion Chips is introduced in material 3 library & right now it’s in beta version. In suggestion chips, there is some suggest data , we can select only one data & content will show according to selected data.

Suggestion chips

In this above image we can see that we have three (india , france , spain) suggest data & we can only select one. Let see how we can make this.

Empty Compose Activity(MATERIAL 3)

Make sure you choose Empty Compose Activity(Material 3) & click on next. Below is the dependencies , be sure you also have the same.

First let’s create layout for our chip, because we will only create one chip & reuse again & again , that’s the beauty of using compose.

As you can see in the above code we have label(title) for chips , selected indicate that which is one selected , & onChipChange lambda function will update the chip state.

If you want to create suggestion chips then we have SuggestionChip Composable function & it takes lot of parameters , onClick {} will change the state of chip , label means title of chip , shape means shape of chips , here we have used RoundedCornerShape(8.dp) , colors here we just change the background color of our chips , if it’s selected , change to purple otherwise transparent , border here we…

--

--

Jayant Kumar🇮🇳
Jayant Kumar🇮🇳

Written by Jayant Kumar🇮🇳

Hello My name is Jayant Kumar, I am a software Engineer , specialist in Mobile Development (Android , IOS , Flutter , React Native) from India 🇮🇳

No responses yet

Write a response