Command
Command

Scoped search

A palette input prefixed with a removable scope chip narrowing the search.

Settings ×Search in Settings

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
@Composable
fun ScopedSearch(scope: String, onClearScope: () -> Unit) {
    var query by remember { mutableStateOf("") }
    Card(shape = RoundedCornerShape(16.dp)) {
        Row(Modifier.padding(12.dp), verticalAlignment = Alignment.CenterVertically) {
            InputChip(
                selected = true,
                onClick = onClearScope,
                label = { Text(scope) },
                trailingIcon = { Icon(Icons.Filled.Close, null, Modifier.size(16.dp)) },
            )
            Spacer(Modifier.width(8.dp))
            BasicTextField(
                value = query,
                onValueChange = { query = it },
                singleLine = true,
                modifier = Modifier.weight(1f),
                decorationBox = { inner ->
                    if (query.isEmpty()) Text("Search in $scope",
                        color = MaterialTheme.colorScheme.onSurfaceVariant)
                    inner()
                },
            )
        }
    }
}