Quick Start
Basic usage
import io.github.aldefy.chiptextfield.ChipTextFieldimport io.github.aldefy.chiptextfield.rememberChipTextFieldState
@Composablefun MyScreen() { val state = rememberChipTextFieldState<String>()
ChipTextField( state = state, onCreateChip = { text -> text.ifBlank { null } }, placeholder = { Text("Type and press Enter...") }, )}That’s it. Type text, press Enter (or type a delimiter like ,), and a chip appears. Press backspace on an empty field to remove the last chip.
With initial chips
val state = rememberChipTextFieldState( initialChips = listOf("Kotlin", "Compose", "Multiplatform"))Custom data types
ChipTextField is generic — use any type, not just strings:
data class Contact(val name: String, val email: String)
val state = rememberChipTextFieldState<Contact>()
ChipTextField( state = state, onCreateChip = { text -> // Parse or validate input, return null to reject Contact(name = text, email = "$text@example.com") }, chipLabel = { it.name }, // display name on chip)Reading chip state
val state = rememberChipTextFieldState<String>()
// Access chips reactivelyval chipCount = state.chips.size
// Programmatic operationsstate.addChip("New chip")state.removeChip("Old chip")state.clearChips()Next steps
- Chip Customization — icons, colors, full custom rendering
- Suggestions — dropdown suggestions as users type
- Validation & Limits — email validation, max chips, delimiters