SyntaxHighlightedTextField

fun SyntaxHighlightedTextField(state: TextFieldState, language: Language, modifier: Modifier = Modifier, theme: SyntaxTheme = LocalSyntaxTheme.current, textStyle: TextStyle = LocalTextStyle.current.copy(fontFamily = FontFamily.Monospace), enabled: Boolean = true, readOnly: Boolean = false, cursorBrush: Brush = SolidColor(MaterialTheme.colorScheme.primary), lineLimits: TextFieldLineLimits = TextFieldLineLimits.MultiLine(), scrollState: ScrollState = rememberScrollState(), keyboardOptions: KeyboardOptions = KeyboardOptions.Default, onKeyboardAction: KeyboardActionHandler? = null, interactionSource: MutableInteractionSource? = null)

Renders an editable, syntax-highlighted code surface backed by IncrementalHighlighter.

Internally layers a transparent BasicTextField beneath a Text that paints the highlighted form, sharing the same TextStyle and ScrollState so glyphs in both children sit at identical positions. The BasicTextField owns cursor, selection, and IME; the overlay Text owns visible colour.

For non-Material3 chrome or custom layouts, use rememberSyntaxHighlightedString directly and compose your own overlay.

Parameters

state

Source of truth for the editable text.

language

Tree-sitter Language driving the highlighting.

theme

Maps capture names to androidx.compose.ui.text.SpanStyles. Defaults to the value of LocalSyntaxTheme.

textStyle

Base text style. The overlay Text uses it as-is; the underlying BasicTextField copies it with Color.Transparent so its glyphs remain invisible while still measuring.

cursorBrush

Caret brush. Defaults to the Material3 primary colour.

lineLimits

Defaults to TextFieldLineLimits.MultiLine — code-editor flow.

scrollState

Vertical scroll. The same instance is shared by overlay and underlay.