GeneralTextField

fun GeneralTextField(value: String, onValueChange: (String) -> Unit, modifier: Modifier = Modifier, style: GeneralTextFieldStyle = GeneralTextFieldStyle.Filled, enabled: Boolean = true, readOnly: Boolean = false, label: String? = null, placeholder: String? = null, supportingText: String? = null, errorText: String? = null, isError: Boolean = errorText != null, leadingIcon: ToolkitIcon? = null, leadingIconContentDescription: String? = null, trailingIcon: ToolkitIcon? = null, trailingIconContentDescription: String? = null, onTrailingIconClick: () -> Unit? = null, trailingContent: @Composable RowScope.() -> Unit? = null, onSearch: (String) -> Unit? = null, singleLine: Boolean = false, minLines: Int = 1, maxLines: Int = if (singleLine) 1 else Int.MAX_VALUE, keyboardOptions: KeyboardOptions = KeyboardOptions.Default, keyboardActions: KeyboardActions = KeyboardActions.Default, visualTransformation: VisualTransformation = VisualTransformation.None, textStyle: TextStyle = LocalTextStyle.current, markdown: GeneralTextFieldMarkdown = GeneralTextFieldMarkdown.None, onMarkdownFormat: (MarkdownFormatAction) -> Unit = {}, position: GroupedItemPosition = GroupedItemPosition.SINGLE, groupedOuterRadius: Dp = SizeConstants.LargeMediumSize, shape: Shape? = null, colors: TextFieldColors? = null, ga4Event: Ga4EventData? = null)(source)

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

value

Text the field shows.

onValueChange

Receives every edit, from typing and from the formatting bar alike.

modifier

The Modifier applied to the field, or to the field and its bar together. The field fills the width it is given either way.

style

Visual treatment; see GeneralTextFieldStyle.

enabled

Whether the field accepts input.

readOnly

Whether the text can be selected and copied but not edited.

label

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.

placeholder

Shown while the field is empty.

supportingText

Line below the field, replaced by errorText while there is an error.

errorText

Message describing the error; non-null also marks the field as errored.

isError

Whether the field is in its error state. Defaults to whether errorText is set.

leadingIcon

Icon before the text. In a group without labels it is what names the field for screen readers, so give it a leadingIconContentDescription.

leadingIconContentDescription

Accessibility description of leadingIcon.

trailingIcon

Icon after the text. With onTrailingIconClick it becomes a button.

trailingIconContentDescription

Accessibility description of trailingIcon.

onTrailingIconClick

Action of the trailing icon, such as clearing the field.

trailingContent

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.

onSearch

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.

singleLine

Whether the field refuses line breaks and scrolls horizontally.

minLines

Rows the field is at least as tall as.

maxLines

Rows the field grows to before it scrolls its own content.

keyboardOptions

Keyboard type, capitalization and IME action.

keyboardActions

What the IME action does.

visualTransformation

Applied to plain fields only; markdown replaces it.

textStyle

Typography of the text itself. Search placeholders use the same style so the typography stays consistent before and after typing begins.

markdown

Markdown support; see GeneralTextFieldMarkdown.

onMarkdownFormat

Reports which formatting action was used, for hosts that log them.

position

Where this field sits in a GeneralTextFieldStyle.Grouped block.

groupedOuterRadius

Corner radius at the outside of that block.

shape

Overrides the resting shape of the field.

colors

Overrides the colors of the field.

ga4Event

Optional GA4 event data, logged when the field gains focus.


fun GeneralTextField(value: TextFieldValue, onValueChange: (TextFieldValue) -> Unit, modifier: Modifier = Modifier, style: GeneralTextFieldStyle = GeneralTextFieldStyle.Filled, enabled: Boolean = true, readOnly: Boolean = false, label: String? = null, placeholder: String? = null, supportingText: String? = null, errorText: String? = null, isError: Boolean = errorText != null, leadingIcon: ToolkitIcon? = null, leadingIconContentDescription: String? = null, trailingIcon: ToolkitIcon? = null, trailingIconContentDescription: String? = null, onTrailingIconClick: () -> Unit? = null, trailingContent: @Composable RowScope.() -> Unit? = null, singleLine: Boolean = false, minLines: Int = 1, maxLines: Int = if (singleLine) 1 else Int.MAX_VALUE, keyboardOptions: KeyboardOptions = KeyboardOptions.Default, keyboardActions: KeyboardActions = KeyboardActions.Default, visualTransformation: VisualTransformation = VisualTransformation.None, textStyle: TextStyle = LocalTextStyle.current, markdown: GeneralTextFieldMarkdown = GeneralTextFieldMarkdown.None, onMarkdownFormat: (MarkdownFormatAction) -> Unit = {}, position: GroupedItemPosition = GroupedItemPosition.SINGLE, groupedOuterRadius: Dp = SizeConstants.LargeMediumSize, shape: Shape? = null, colors: TextFieldColors? = null, ga4Event: Ga4EventData? = null)(source)

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.