androidx.compose.material3
SearchBarStateSince 1.9Experimental
Class
No hand-written docs yet.
The state of a search bar.
class SearchBarState
How to get one
Ready-made values and functions that return it
Used by
Parameters that take a SearchBarState.
AppBarWithSearch(state)ExpandedDockedSearchBar(state)ExpandedDockedSearchBarWithGap(state)ExpandedFullScreenContainedSearchBar(state)ExpandedFullScreenSearchBar(state)SearchBar(state)SearchBarDefaults.InputField(searchBarState)SearchBarDefaults.containedColors(state)
Properties
collapsedCoords
val collapsedCoords: LayoutCoordinates?
The layout coordinates, if available, of the search bar when it is collapsed. Used to coordinate the expansion animation.
progress
val progress: Float
The animation progress of the search bar, where 0 represents SearchBarValue.Collapsed and 1 represents SearchBarValue.Expanded.
isAnimating
val isAnimating: Boolean
Whether the state is currently animating
targetValue
val targetValue: SearchBarValue
Whether the search bar is going to be expanded or collapsed.
currentValue
val currentValue: SearchBarValue
Whether the search bar is currently expanded or collapsed. If the search bar is currently animating to/from the expanded state, currentValue is SearchBarValue.Expanded until the animation completes.
Functions
animateToExpanded
fun animateToExpanded()
Animate the search bar to its expanded state.
animateToCollapsed
fun animateToCollapsed()
Animate the search bar to its collapsed state.
snapTo
fun snapTo(fraction: Float)
Snap the search bar progress to the given fraction, where 0 represents SearchBarValue.Collapsed and 1 represents SearchBarValue.Expanded.
Saver
fun Saver(animationSpecForExpand: AnimationSpec<Float>, animationSpecForCollapse: AnimationSpec<Float>): Saver<SearchBarState, *>
The default Saver implementation for SearchBarState.
fun Saver(
animationSpecForExpand: AnimationSpec<Float>,
animationSpecForCollapse: AnimationSpec<Float>,
animationSpecForContentFadeIn: AnimationSpec<Float>,
animationSpecForContentFadeOut: AnimationSpec<Float>,
): Saver<SearchBarState, *>
The default Saver implementation for SearchBarState.
Library docs
The state of a search bar.