TextField¶
@Composable
fun TextField(
value: TextFieldValue,
onValueChange: (TextFieldValue) -> 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 fully controlled text field composable with the default Minecraft widget appearance.
Supports single-line and multi-line modes, cursor navigation, text selection, clipboard operations, and an optional scrollbar for multi-line overflow.
Use BasicTextField if you only need a simple String-based API. Use this composable when you need full control over TextFieldValue (e.g. selection or IME state).
Parameters¶
-
value: The current
TextFieldValue. -
onValueChange: Called on every edit with the new
TextFieldValue. -
modifier: Additional modifiers.
-
enabled: Whether the field accepts input.
-
readOnly: Whether the field permits editing.
-
textColor: Text colour.
-
cursorColor: Cursor colour.
-
selectionColor: Selection highlight colour.
-
font: The Font used for rendering.
-
singleLine: Single vs multi-line mode.
-
maxLength: Character cap.
-
maxLines: Line cap (multi-line only).