Inputs
Inputsiconanimated
Voice search
Search field with a trailing mic button that pulses while it is listening.
Installation
caveui components are copy-paste Jetpack Compose built entirely on Material 3 — there's no caveui dependency to add. Make sure Material 3 is on your classpath (it ships with the Compose BOM), then copy the Usage snippet below into your project.
kotlin
// build.gradle.kts (module)
dependencies {
implementation(platform("androidx.compose:compose-bom:2025.06.00"))
implementation("androidx.compose.material3:material3")
}Usage
kotlin
var q by remember { mutableStateOf("") }
var listening by remember { mutableStateOf(false) }
val scale by animateFloatAsState(
if (listening) 1.2f else 1f, label = "mic",
)
OutlinedTextField(
value = q,
onValueChange = { q = it },
leadingIcon = { Icon(Icons.Filled.Search, null) },
trailingIcon = {
IconButton(onClick = { listening = !listening }) {
Icon(
Icons.Filled.Mic,
contentDescription = "Voice search",
modifier = Modifier.graphicsLayer {
scaleX = scale; scaleY = scale
},
tint = if (listening)
MaterialTheme.colorScheme.primary
else LocalContentColor.current,
)
}
},
placeholder = { Text("Search…") },
shape = RoundedCornerShape(50),
)