KwikOutlinedTextField

fun KwikOutlinedTextField(modifier: Modifier = Modifier, value: MutableState<TextFieldValue>, onValueChange: (TextFieldValue) -> Unit, onKeyboardDone: () -> Unit = { }, onActionClick: () -> Unit = { }, onFocusChanged: (Boolean) -> Unit = { }, visualTransformation: VisualTransformation = VisualTransformation.None, isEditable: Boolean = true, placeholder: String, shape: Shape = MaterialTheme.shapes.medium, isError: Boolean = false, error: String = "Field is required", singleLine: Boolean = true, maxLength: Int = 65, keyboardType: KeyboardType = KeyboardType.Text, keyboardActions: KeyboardActions = KeyboardActions( onDone = { onKeyboardDone() } ), maxLines: Int = 1, allowedChars: Regex? = AllowedChars.ALL, imeAction: ImeAction = ImeAction.Done, isValid: Boolean = false, isTextCounterShown: Boolean = false, hint: Any? = null, hintVisibleOnError: Boolean = false, leadingIcon: Any? = null, trailingIcon: Any? = null, showClearTextButton: Boolean = false, isLoading: Boolean = false, isBigTextField: Boolean = false, enabled: Boolean = true, textStyle: TextStyle = MaterialTheme.typography.bodyMedium, suggestionsModifier: Modifier = Modifier, onSuggestionSelected: (String) -> Unit = {}, suggestions: List<String> = listOf(), suggestionsContainerColor: Color = MaterialTheme.colorScheme.surface, delay: Boolean = false, delayDuration: Long = 500, colors: TextFieldColors = kwikOutlinedTextFieldColors(enabled))

A versatile filled text field component that can be used to take user input.

Parameters

modifier

: The modifier for the text field.

value

: The value of the text field.

onValueChange

: The callback that will be called when the value of the text field changes.

onKeyboardDone

: The callback that will be called when the keyboard action is done.

onActionClick

: The callback that will be called when the action icon is clicked.

onFocusChanged

: The callback that will be called when the focus of the text field changes.

visualTransformation

: The visual transformation of the text field. Refer to VisualTransformation.

isEditable

: If true, the text field is editable. Default is true.

placeholder

: The placeholder text of the text field.

shape

: The shape of the text field. Default is RoundedCornerShape.

isError

: If true, the text field will display an error state.

error

: The error message to display when isError is true.

singleLine

: If true, the text field will be single line. Default is true.

maxLength

: The maximum length of the text field. Default is 35.

keyboardType

: The keyboard type of the text field. Default is KeyboardType.Text.

keyboardActions

: The keyboard actions of the text field. Default is KeyboardActions with onDone action.

maxLines

: The maximum number of lines of the text field. Default is 1.

allowedChars

: The allowed characters in the text field. Default is AllowedChars.ALL.

imeAction

: The IME action of the text field. Default is ImeAction.Done.

isValid

: If true, the text field will display a valid state.

isTextCounterShown

: If true, the text counter will be shown.

hint

: The hint text of the text field.

hintVisibleOnError

: If true, the hint will be visible only when there is an error.

leadingIcon

: The leading icon of the text field.

trailingIcon

: The trailing icon of the text field.

showClearTextButton

: If true, the clear text button will be shown.

isLoading

: If true, the loading indicator will be shown.

isBigTextField

: If true, the text field will be big.

enabled

: If true, the text field will be enabled. Default is true.

colors

: The colors of the text field. Default is OutlinedTextFieldDefaults.colors.

Example usage:

val pirateName = rememberSaveable(stateSaver = TextFieldValue.Saver) {
mutableStateOf(TextFieldValue(""))
}

KwikOutlinedTextField(
value = pirateName,
onValueChange = {
pirateName.value = it
},
placeholder = "Jack Sparrow",
keyboardType = KeyboardType.Phone,
visualTransformation = VisualTransformation.None,
imeAction = ImeAction.Done,
)