Skip to content

BasicTextField

@Composable



fun BasicTextField(
    value: String, 
    onValueChange: (String) -> Unit, 
    modifier: Modifier = Modifier, 
    enabled: Boolean = true, 
    readOnly: Boolean = false, 
    textColor: KColor = KColor.ofRgb(0xE0E0E0), 
    cursorColor: KColor = KColor.ofRgb(0xFFD0D0D0.toInt()), 
    selectionColor: KColor = KColor.ofRgb(-16776961), 
    font: Font = Minecraft.getInstance().font, 
    singleLine: Boolean = true, 
    maxLength: Int = Int.MAX_VALUE, 
    maxLines: Int = if (singleLine) 1 else Int.MAX_VALUE
)

A simple, controlled text field that uses a plain String as its state.

This is a convenience wrapper around TextField that manages a TextFieldValue internally, converting to and from String for the onValueChange callback.

Parameters

  • value: The current text string.

  • onValueChange: Called with the updated string on every edit.

  • modifier: Additional modifiers applied to the text field.

  • enabled: When false, input is ignored and the field appears disabled.

  • readOnly: When true, text can be selected and copied but not edited.

  • textColor: ARGB colour of the rendered text.

  • cursorColor: ARGB colour of the blinking cursor line.

  • selectionColor: ARGB colour of the text-selection highlight.

  • font: The Font used for rendering and measurement.

  • singleLine: When true the field occupies a single horizontal line.

  • maxLength: Maximum allowed character count.

  • maxLines: Maximum allowed line count (multi-line only).