Skip to main content

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​

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​

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,
)
NameTypeDefault
valueStringrequired
onValueChange(String) -> Unitrequired
modifierModifierModifier
labelString?null
placeholderString?null
supportingTextString?null
errorString?null
prefixIcon(@Composable () -> Unit)?null
suffixIcon(@Composable () -> Unit)?null
prefixTextString?null
suffixTextString?null
enabledBooleantrue
singleLineBooleantrue
secureBooleanfalse
onFocusChanged((Boolean) -> Unit)?null
inputFilterCamoInputFilter?null
displayFormatCamoDisplayFormat?null
keyboardOptionsKeyboardOptionsKeyboardOptions.Default
onKeyboardActionKeyboardActionHandler?null
interactionSourceMutableInteractionSource?null
Design notes

Why CamoTextField works this way, its states and its edge cases: contributor docs.