SyntaxHighlightedTextField
Renders an editable, syntax-highlighted code surface backed by IncrementalHighlighter.
A single BasicTextField owns the one and only text layout, cursor, selection, and IME. Highlighting is painted onto that same layout by a rememberSyntaxHighlightVisualTransformation, so glyph metrics, caret position, and color are always measured from one layout — there is no second layer to drift against. The highlight is computed asynchronously and may lag the caret by a few frames; the caret position itself is always exact.
For non-Material3 chrome or custom layouts, use rememberSyntaxHighlightVisualTransformation directly on your own BasicTextField.
Parameters
Source of truth for the editable text and selection.
Invoked with the updated TextFieldValue on every edit.
Tree-sitter Language driving the highlighting.
Maps capture names to androidx.compose.ui.text.SpanStyles. Defaults to the value of LocalSyntaxTheme.
Base text style; applied to the field and inherited by the highlight spans.
Whether the field accepts input. Defaults to true.
Whether the field's contents can be modified. Defaults to false.
Caret brush. Defaults to the Material3 primary colour.
Defaults to false — code-editor flow.
Defaults to unbounded.
Defaults to 1.
Callbacks invoked for IME actions (e.g. Done, Next). Defaults to none.