← Back to Foundation text
CoreTextField
Component
in
Foundation text
. Since 0.1.0-dev15Overview
Examples
Community Notes
Base composable that enables users to edit text via hardware or software keyboard.
This composable provides basic text editing functionality, however does not include any decorations such as borders, hints/placeholder.
Whenever the user edits the text, onValueChange is called with the most up to date state represented by TextFieldValue. TextFieldValue contains the text entered by user, as well as selection, cursor and text composition information. Please check TextFieldValue for the description of its contents.
It is crucial that the value provided in the onValueChange is fed back into CoreTextField in order to have the final state of the text being displayed.
Overloads
CoreTextField
@Composable
@OptIn(
ExperimentalFocus::class,
ExperimentalTextApi::class,
MouseTemporaryApi::class
)
@InternalTextApi
fun CoreTextField(
value: TextFieldValue,
modifier: Modifier = Modifier,
onValueChange: (TextFieldValue) -> Unit,
textStyle: TextStyle = TextStyle.Default,
onImeActionPerformed: (ImeAction) -> Unit = {},
visualTransformation: VisualTransformation = VisualTransformation.None,
onTextLayout: (TextLayoutResult) -> Unit = {},
onTextInputStarted: (SoftwareKeyboardController) -> Unit = {},
cursorColor: Color = Color.Unspecified,
softWrap: Boolean = true,
maxLines: Int = Int.MAX_VALUE,
imeOptions: ImeOptions = ImeOptions.Default
)
Parameters
Name | Description |
---|---|
value | The androidx.compose.ui.text.input.TextFieldValue to be shown in the CoreTextField. |
onValueChange | Called when the input service updates the values in TextFieldValue. |
modifier | optional Modifier for this text field. |
textStyle | Style configuration that applies at character level such as color, font etc. |
onImeActionPerformed | Called when the input service requested an IME action. When the input service emitted an IME action, this callback is called with the emitted IME action. Note that this IME action may be different from what you specified in imeAction. |
visualTransformation | The visual transformation filter for changing the visual representation of the input. By default no visual transformation is applied. |
onTextLayout | Callback that is executed when a new text layout is calculated. |
onTextInputStarted | Callback that is executed when the initialization has done for communicating with platform text input service, e.g. software keyboard on Android. Called with SoftwareKeyboardController instance which can be used for requesting input show/hide software keyboard. |
cursorColor | Color of the cursor. If Color.Unspecified, there will be no cursor drawn |
softWrap | Whether the text should break at soft line breaks. If false, the glyphs in the text will be positioned as if there was unlimited horizontal space. |
maxLines | the maximum height in terms of maximum number of visible lines. Should be equal or greater than 1 |
Previous Component← CoreText