Skip to content

Instantly share code, notes, and snippets.

@Starchild13
Created January 15, 2024 07:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Starchild13/6107b45e9217f43d6a62e8e4422602d7 to your computer and use it in GitHub Desktop.
Save Starchild13/6107b45e9217f43d6a62e8e4422602d7 to your computer and use it in GitHub Desktop.
// Annotation to use experimental API for Material3 components
@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun ChipItem(text: String, selected: MutableState<String>) {
// Defining a FilterChip composable
FilterChip(
modifier = Modifier.padding(end = 16.dp), // Adding padding to the end of the chip
selected = selected.value === text, // Chip is selected if its text matches the selected value
onClick = { selected.value = text }, // On click, set the chip's text as the selected value
label = { Text(text) } // Displaying the given text on the chip
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment