androidx.compose.material3
AppBarWithSearchSince 1.10Experimental
Composable function
One of the search bar types. It works like SearchBar. Only the parameters that differ are described here.
A top app bar with a search field in the middle and room for icons on both sides.

val text = rememberTextFieldState()
val state = rememberSearchBarState()
AppBarWithSearch(
state = state,
inputField = {
SearchBarDefaults.InputField(
textFieldState = text,
searchBarState = state,
onSearch = {},
placeholder = { Text("Search photos") },
)
},
navigationIcon = { IconButton(onClick = {}) { Icon(Icons.Filled.Menu, "Menu") } },
actions = { IconButton(onClick = {}) { Icon(Icons.Filled.Person, "Account") } },
modifier = Modifier.width(400.dp),
)
ParametersExperimental
@Composable
fun AppBarWithSearch(
state: SearchBarState,
inputField: @Composable () -> Unit,
modifier: Modifier = Modifier,
navigationIcon: @Composable (() -> Unit)? = null,
actions: @Composable (RowScope.() -> Unit)? = null,
shape: Shape = SearchBarDefaults.inputFieldShape,
colors: AppBarWithSearchColors = SearchBarDefaults.appBarWithSearchColors(),
tonalElevation: Dp = SearchBarDefaults.TonalElevation,
shadowElevation: Dp = SearchBarDefaults.ShadowElevation,
contentPadding: PaddingValues = SearchBarDefaults.AppBarContentPadding,
windowInsets: WindowInsets = SearchBarDefaults.windowInsets,
scrollBehavior: SearchBarScrollBehavior? = null,
)
navigationIcon: @Composable (() -> Unit)?Optional
navigationIcon: @Composable (() -> Unit)?OptionalDefault: null
A button before the field in AppBarWithSearch, like back or menu.
actions: @Composable (RowScope.() -> Unit)?Optional
actions: @Composable (RowScope.() -> Unit)?OptionalDefault: null
Buttons after the field in AppBarWithSearch.
colors: AppBarWithSearchColorsOptional
colors: AppBarWithSearchColorsOptionalDefault: SearchBarDefaults.appBarWithSearchColors()
Sets the container and field colors. Make one with SearchBarDefaults.colors.
contentPadding: PaddingValuesOptional
contentPadding: PaddingValuesOptionalDefault: SearchBarDefaults.AppBarContentPadding
Space between the edge of the app bar and its content.
scrollBehavior: SearchBarScrollBehavior?Optional
scrollBehavior: SearchBarScrollBehavior?OptionalDefault: null
Hides AppBarWithSearch while the user scrolls.
Same as in SearchBar: state, inputField, modifier, shape, tonalElevation, shadowElevation, windowInsets.
Search bar types
SearchBarDockedSearchBarAppBarWithSearchExpandedFullScreenSearchBarExpandedFullScreenContainedSearchBarExpandedDockedSearchBarExpandedDockedSearchBarWithGap
See also
SearchBarDefaults: default values and helper functions forAppBarWithSearch.