InputField

@Composable
fun InputField(query: String, onQueryChange: (String) -> Unit, onSearch: (String) -> Unit, expanded: Boolean, onExpandedChange: (Boolean) -> Unit, modifier: Modifier = Modifier, enabled: Boolean = true, placeholder: @Composable () -> Unit? = null, leadingIcon: @Composable () -> Unit? = null, trailingIcon: @Composable () -> Unit? = null, colors: TextFieldColors = inputFieldColors(), interactionSource: MutableInteractionSource? = null)

A text field to input a query in a search bar

Parameters

query

the query text to be shown in the input field.

onQueryChange

the callback to be invoked when the input service updates the query. An updated text comes as a parameter of the callback.

onSearch

the callback to be invoked when the input service triggers the ImeAction.Search action. The current query comes as a parameter of the callback.

expanded

whether the search bar is expanded and showing search results.

onExpandedChange

the callback to be invoked when the search bar's expanded state is changed.

modifier

the Modifier to be applied to this input field.

enabled

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.

placeholder

the placeholder to be displayed when the query is empty.

leadingIcon

the leading icon to be displayed at the start of the input field.

trailingIcon

the trailing icon to be displayed at the end of the input field.

colors

TextFieldColors that will be used to resolve the colors used for this input field in different states. See SearchBarDefaults.inputFieldColors.

interactionSource

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.