Inputs
Inputsnumber

Quantity unit

Quantity field with an attached unit selector for entering measured amounts.

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 qty by remember { mutableStateOf("") }
var unit by remember { mutableStateOf("g") }
OutlinedTextField(
    value = qty,
    onValueChange = { qty = it.filter(Char::isDigit) },
    trailingIcon = {
        TextButton(onClick = {
            unit = if (unit == "g") "kg" else "g"
        }) { Text(unit) }
    },
    placeholder = { Text("0") },
    keyboardOptions = KeyboardOptions(
        keyboardType = KeyboardType.Number,
    ),
    singleLine = true,
)