GeneralTextField
The toolkit's text field: a Material field with the toolkit's grouped styling, icon slot and Markdown authoring available as options rather than as separate components.
It is the input counterpart of GeneralButton: one entry point, native defaults, and every variation reachable through a parameter. The defaults render exactly the Material filled field.
errorText both marks the field as errored and replaces supportingText beneath it, so the message and the state cannot drift apart. Pass isError on its own to mark the state without a message.
GeneralTextFieldStyle.Search draws the Material search input instead, for a field that filters what is behind it as it is typed. It leads with a search icon unless leadingIcon names another, and the parameters describing a form field do not apply to it; see the style's own documentation.
markdown is what makes this field a Markdown editor: GeneralTextFieldMarkdown.Highlight styles the syntax as it is typed, and GeneralTextFieldMarkdown.Editor adds the formatting bar under the field. Both replace visualTransformation, because the field draws the Markdown source itself. The bar edits that source and moves the caret, which is why this overload keeps the selection of its own: the caller owns the text, the field owns the caret. Where a caller needs the caret too, the TextFieldValue overload hands both over.
ga4Event is logged once each time the field gains focus, which is the moment a person starts writing in it; a field is not a button, so there is no per-keystroke event.
Parameters
Text the field shows.
Receives every edit, from typing and from the formatting bar alike.
The Modifier applied to the field, or to the field and its bar together. The field fills the width it is given either way.
Visual treatment; see GeneralTextFieldStyle.
Whether the field accepts input.
Whether the text can be selected and copied but not edited.
Floating label. A field inside a group usually leaves this null, because the label reserves height whether or not it is showing, and states itself through placeholder instead.
Shown while the field is empty.
Line below the field, replaced by errorText while there is an error.
Message describing the error; non-null also marks the field as errored.
Whether the field is in its error state. Defaults to whether errorText is set.
Icon before the text. In a group without labels it is what names the field for screen readers, so give it a leadingIconContentDescription.
Accessibility description of leadingIcon.
Icon after the text. With onTrailingIconClick it becomes a button.
Accessibility description of trailingIcon.
Action of the trailing icon, such as clearing the field.
Replaces the whole trailing slot with a row of your own, for a field that ends in more than one action, such as a search box carrying both a filter and a clear button. It supersedes trailingIcon.
Called by GeneralTextFieldStyle.Search when the keyboard's search action is used. The field always drops focus first, so a filter that already applied itself as it was typed needs nothing here.
Whether the field refuses line breaks and scrolls horizontally.
Rows the field is at least as tall as.
Rows the field grows to before it scrolls its own content.
Keyboard type, capitalization and IME action.
What the IME action does.
Applied to plain fields only; markdown replaces it.
Typography of the text itself. Search placeholders use the same style so the typography stays consistent before and after typing begins.
Markdown support; see GeneralTextFieldMarkdown.
Reports which formatting action was used, for hosts that log them.
Where this field sits in a GeneralTextFieldStyle.Grouped block.
Corner radius at the outside of that block.
Overrides the resting shape of the field.
Overrides the colors of the field.
Optional GA4 event data, logged when the field gains focus.
TextFieldValue variant, for callers that own the caret as well as the text.
A Markdown editor needs exactly this, because its formatting actions place the caret between the markers they insert. Take this overload when the caret is part of the state a screen restores, and the String one otherwise.
Every parameter behaves as it does on the String overload, except that GeneralTextFieldStyle.Search is rejected: the Material search input owns its own text state, so there is no caret for this overload to hand over.