JengaSearchField

fun JengaSearchField(value: String, onValueChange: (String) -> Unit, placeholder: String, clearContentDescription: String, modifier: Modifier = Modifier, enabled: Boolean = true, onClear: () -> Unit? = null, trailingContent: @Composable () -> Unit? = null, supportingContent: @Composable () -> Unit? = null, shape: Shape = JengaTheme.components.searchField?.shape ?: JengaSearchFieldDefaults.shape, colors: JengaTextFieldColors = JengaTheme.components.searchField?.colors ?: JengaTextFieldDefaults.colors(), textStyle: TextStyle = JengaTheme.components.searchField?.textStyle ?: JengaTextFieldDefaults.textStyle, minHeight: Dp = JengaTheme.components.searchField?.minHeight ?: JengaTextFieldDefaults.minHeight, contentPadding: PaddingValues = JengaTheme.components.searchField?.contentPadding ?: JengaTextFieldDefaults.contentPadding, keyboardOptions: KeyboardOptions = KeyboardOptions.Default, keyboardActions: KeyboardActions = KeyboardActions.Default)(source)

A search input: a JengaTextField with a leading search icon and a clear button that appears once there's text. While the query is empty, the trailingContent slot (e.g. a scan button) takes the clear button's place.

Parameters

value

the current query.

onValueChange

called when the query changes.

placeholder

hint shown when empty (e.g. "Search tickets").

clearContentDescription

accessibility label for the clear button.

modifier

the Modifier for this field.

enabled

whether the field is editable.

onClear

called when the clear button is tapped; defaults to clearing the text.

trailingContent

optional end slot shown while the query is empty.

supportingContent

optional slot below the field (e.g. a hint).

shape

the field shape; defaults to the theme's search field style, else JengaSearchFieldDefaults.shape.

colors

the color set; defaults to the theme's search field style, else JengaTextFieldDefaults.colors.

textStyle

the query and placeholder text style.

minHeight

the minimum height of the field.

contentPadding

padding inside the field.

keyboardOptions

software-keyboard configuration (e.g. a number pad, the Search key).

keyboardActions

IME action handlers (e.g. run the search when Search is pressed).

Samples

var query by remember {
    mutableStateOf(
        value = "",
    )
}
JengaSearchField(
    value = query,
    onValueChange = { query = it },
    placeholder = "Search tickets",
    clearContentDescription = "Clear search",
)