CamoTextField
A controlled text field. value is raw text: inputFilter blocks or trims input before it reaches
onValueChange, and displayFormat shows formatting (dashes, thousand separators) without storing it, with
the cursor kept in place. If the app doesn't take a change, the field keeps showing value. error replaces
supportingText and marks it invalid. prefixText / suffixText ("+62", "kg") are never part of the value.
The editable node lives here, not in the skin, so switching skins while typing keeps focus and selection.
Usage
- Kotlin
- Dart
var email by remember { mutableStateOf("") }
CamoTextField(
value = email,
onValueChange = { email = it },
label = "Email",
supportingText = "We never share it",
error = if (email.isNotEmpty() && '@' !in email) "Enter a valid email" else null,
keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Email),
)
API
- Kotlin
- Dart
public fun CamoTextField(
value: String,
onValueChange: (String) -> Unit,
modifier: Modifier = Modifier,
label: String? = null,
placeholder: String? = null,
supportingText: String? = null,
error: String? = null,
prefixIcon: (@Composable () -> Unit)? = null,
suffixIcon: (@Composable () -> Unit)? = null,
prefixText: String? = null,
suffixText: String? = null,
enabled: Boolean = true,
singleLine: Boolean = true,
secure: Boolean = false,
onFocusChanged: ((Boolean) -> Unit)? = null,
inputFilter: CamoInputFilter? = null,
displayFormat: CamoDisplayFormat? = null,
keyboardOptions: KeyboardOptions = KeyboardOptions.Default,
onKeyboardAction: KeyboardActionHandler? = null,
interactionSource: MutableInteractionSource? = null,
)
| Name | Type | Default |
|---|---|---|
value | String | required |
onValueChange | (String) -> Unit | required |
modifier | Modifier | Modifier |
label | String? | null |
placeholder | String? | null |
supportingText | String? | null |
error | String? | null |
prefixIcon | (@Composable () -> Unit)? | null |
suffixIcon | (@Composable () -> Unit)? | null |
prefixText | String? | null |
suffixText | String? | null |
enabled | Boolean | true |
singleLine | Boolean | true |
secure | Boolean | false |
onFocusChanged | ((Boolean) -> Unit)? | null |
inputFilter | CamoInputFilter? | null |
displayFormat | CamoDisplayFormat? | null |
keyboardOptions | KeyboardOptions | KeyboardOptions.Default |
onKeyboardAction | KeyboardActionHandler? | null |
interactionSource | MutableInteractionSource? | null |
Design notes
Why CamoTextField works this way, its states and its edge cases: contributor docs.