Created
January 15, 2024 07:12
-
-
Save Starchild13/6107b45e9217f43d6a62e8e4422602d7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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