androidx.compose.material3

ExpandedFullScreenSearchBarSince 1.9Experimental

Composable function

One of the search bar types. It works like SearchBar. Only the parameters that differ are described here.

What a SearchBar turns into when the user taps it: a full screen with the field and your results. Pass it the same state and field as the SearchBar.

Expanded to the full screenExpressive theme
Expanded to the full screen
val text = rememberTextFieldState()
val state = rememberSearchBarState(SearchBarValue.Expanded)
val field = @Composable {
    SearchBarDefaults.InputField(textFieldState = text, searchBarState = state, onSearch = {}, placeholder = { Text("Search photos") })
}
Box(Modifier.size(360.dp, 360.dp)) {
    SearchBar(state = state, inputField = field)
    ExpandedFullScreenSearchBar(state = state, inputField = field) { Suggestions() }
}

@Composable
fun Suggestions() {
    listOf("Beach", "Mountains", "Snow").forEach {
        ListItem(
            headlineContent = { Text(it) },
            leadingContent = { Icon(Icons.Filled.Search, null) },
            colors = ListItemDefaults.colors(containerColor = Color.Transparent),
        )
    }
}

ParametersExperimental

@Composable
fun ExpandedFullScreenSearchBar(
    state: SearchBarState,
    inputField: @Composable () -> Unit,
    modifier: Modifier = Modifier,
    collapsedShape: Shape = SearchBarDefaults.inputFieldShape,
    colors: SearchBarColors = SearchBarDefaults.colors(),
    tonalElevation: Dp = SearchBarDefaults.TonalElevation,
    shadowElevation: Dp = SearchBarDefaults.ShadowElevation,
    windowInsets: @Composable () -> WindowInsets = { SearchBarDefaults.fullScreenWindowInsets },
    properties: DialogProperties = DialogProperties(),
    content: @Composable ColumnScope.() -> Unit,
)

collapsedShape: ShapeOptional

Default: SearchBarDefaults.inputFieldShape

The outline of the field before the full-screen bar opens.

windowInsets: @Composable () -> WindowInsetsOptional

Default: { SearchBarDefaults.fullScreenWindowInsets }

Space kept free for system bars. The default is usually right.

properties: DialogPropertiesOptional

Default: DialogProperties()

Window options for the expanded bar, like whether back closes it.

Same as in SearchBar: state, inputField, modifier, colors, tonalElevation, shadowElevation, content.

Search bar types

See also