Chip

Add chips to your apps built with Jetpack Compose!

To get started with Chip just add the maven url and the Chip dependency

build.gradle (Project level)

allprojects {
    repositories {
    ...
    //Add this url
    maven { url 'https://jitpack.io' }
    }
}

If you are using Android Studio Arctic Fox and above where you don’t have allProjects in build.gradle then add following maven url in settings.gradle like below

dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        google()
        mavenCentral()
        //Add this url
        maven { url 'https://jitpack.io' }
        jcenter() // Warning: this repository is going to shut down soon
    }
}

Once you have added the maven url now add the Chip dependency in the build.gradle (module level)

implementation 'com.github.raipankaj:Chip:1.0.0'

Congratulations, you have successfully added the dependency.
Now to get started with Chip add the following code snippet

val chipAssistItem = listOf(
                        ChipItem("Account", ChipType.Assist(Icons.Default.AccountBox)),
                        ChipItem("Search", ChipType.Assist(Icons.Default.Search)),
                        ChipItem("Filter", ChipType.Assist(Icons.Default.List))
                    )

Chip(labels = chipAssistItem) { selectedChip ->
    //Your logic based on selected chip
}

Chip composable provide an ability to change the background color of chip, default text color and text color when chip is selected.
Here are all the parameters accepted by Chip composable.

fun Chip(labels: List<ChipItem>,
         defaultTextColor: Color = Color.Black,
         selectedTextColor: Color = Color.White,
         chipColor: Color = Color.Blue.copy(0.5f),
         chipOnClick: (String) -> Unit) 

The various types of Chips that are currently supported are

1. Assist
2. Filter
3. Suggestion

Demo

Note: If you like this library, then please hit the star button! ?

GitHub

View Github