InputField
A text field to input a query in a search bar.
This overload of InputField uses TextFieldState to keep track of the text content and position of the cursor or selection, and SearchBarState to keep track of the state of the search bar. It should be used with the search bar APIs which also accept a SearchBarState.
Parameters
TextFieldState that holds the internal editing state of the input field.
the state of the search bar as a whole.
the callback to be invoked when the input service triggers the ImeAction.Search action. The current query in the textFieldState comes as a parameter of the callback.
the Modifier to be applied to this input field.
the enabled state of this input field. When false, this component will not respond to user input, and it will appear visually disabled and disabled to accessibility services.
controls the editable state of the input field. When true, the field cannot be modified. However, a user can focus it and copy text from it.
the style to be applied to the input text. Defaults to LocalTextStyle.
the placeholder to be displayed when the input text is empty.
the leading icon to be displayed at the start of the input field.
the trailing icon to be displayed at the end of the input field.
the optional prefix to be displayed before the input text.
the optional suffix to be displayed after the input text.
optional InputTransformation that will be used to transform changes to the TextFieldState made by the user. The transformation will be applied to changes made by hardware and software keyboard events, pasting or dropping text, accessibility services, and tests. The transformation will not be applied when changing the textFieldState programmatically, or when the transformation is changed. If the transformation is changed on an existing text field, it will be applied to the next user edit. The transformation will not immediately affect the current textFieldState.
optional OutputTransformation that transforms how the contents of the text field are presented.
software keyboard options that contains configuration such as KeyboardType. Note that the ImeAction will always be overwritten with ImeAction.Search.
whether the text field should be TextFieldLineLimits.SingleLine, scroll horizontally, and ignore newlines; or TextFieldLineLimits.MultiLine and grow and scroll vertically.
scroll state that manages the horizontal scroll of the input field.
the shape of the input field.
TextFieldColors that will be used to resolve the colors used for this input field in different states. See SearchBarDefaults.inputFieldColors.
an optional hoisted MutableInteractionSource for observing and emitting Interactions for this input field. You can use this to change the search bar's appearance or preview the search bar in different states. Note that if null is provided, interactions will still happen internally.
A text field to input a query in a search bar.
This overload of InputField uses TextFieldState to keep track of the text content and position of the cursor or selection, and expanded and onExpandedChange to keep track of the state of the search bar. It should be used with the search bar APIs which also accept expanded and onExpandedChange.
Parameters
TextFieldState that holds the internal editing state of the input field.
the callback to be invoked when the input service triggers the ImeAction.Search action. The current query in the state comes as a parameter of the callback.
whether the search bar is expanded and showing search results.
the callback to be invoked when the search bar's expanded state is changed.
the Modifier to be applied to this input field.
the enabled state of this input field. When false, this component will not respond to user input, and it will appear visually disabled and disabled to accessibility services.
controls the editable state of the input field. When true, the field cannot be modified. However, a user can focus it and copy text from it.
the style to be applied to the input text. Defaults to LocalTextStyle.
the placeholder to be displayed when the input text is empty.
the leading icon to be displayed at the start of the input field.
the trailing icon to be displayed at the end of the input field.
the optional prefix to be displayed before the input text.
the optional suffix to be displayed after the input text.
optional InputTransformation that will be used to transform changes to the TextFieldState made by the user. The transformation will be applied to changes made by hardware and software keyboard events, pasting or dropping text, accessibility services, and tests. The transformation will not be applied when changing the state programmatically, or when the transformation is changed. If the transformation is changed on an existing text field, it will be applied to the next user edit. The transformation will not immediately affect the current state.
optional OutputTransformation that transforms how the contents of the text field are presented.
scroll state that manages the horizontal scroll of the input field.
the shape of the input field.
TextFieldColors that will be used to resolve the colors used for this input field in different states. See SearchBarDefaults.inputFieldColors.
an optional hoisted MutableInteractionSource for observing and emitting Interactions for this input field. You can use this to change the search bar's appearance or preview the search bar in different states. Note that if null is provided, interactions will still happen internally.
A text field to input a query in a search bar.
This overload of InputField takes a query and onQueryChange callback to keep track of the text content. Consider using the overload which takes a TextFieldState instead.
Parameters
the query text to be shown in the input field.
the callback to be invoked when the input service updates the query. An updated text comes as a parameter of the callback.
the callback to be invoked when the input service triggers the ImeAction.Search action. The current query comes as a parameter of the callback.
whether the search bar is expanded and showing search results.
the callback to be invoked when the search bar's expanded state is changed.
the Modifier to be applied to this input field.
the enabled state of this input field. When false, this component will not respond to user input, and it will appear visually disabled and disabled to accessibility services.
the placeholder to be displayed when the query is empty.
the leading icon to be displayed at the start of the input field.
the trailing icon to be displayed at the end of the input field.
TextFieldColors that will be used to resolve the colors used for this input field in different states. See SearchBarDefaults.inputFieldColors.
an optional hoisted MutableInteractionSource for observing and emitting Interactions for this input field. You can use this to change the search bar's appearance or preview the search bar in different states. Note that if null is provided, interactions will still happen internally.