androidx.compose.material3

ExpandedFullScreenContainedSearchBarSince 1.11Experimental

Composable function

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

Like ExpandedFullScreenSearchBar, but the field keeps its pill shape and the results sit in a box under it.

Expanded to the full screen, contained styleExpressive theme
Expanded to the full screen, contained style
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)
    ExpandedFullScreenContainedSearchBar(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 ExpandedFullScreenContainedSearchBar(
    state: SearchBarState,
    inputField: @Composable () -> Unit,
    modifier: Modifier = Modifier,
    collapsedShape: Shape = SearchBarDefaults.inputFieldShape,
    colors: SearchBarColors = SearchBarDefaults.containedColors(state = state),
    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.

Defaults that differ from SearchBar:

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

Search bar types

See also