SearchBarDefaults

Defaults used in SearchBar and DockedSearchBar.

Properties

Link copied to clipboard
val AppBarContentPadding: PaddingValues

Default padding used for AppBarWithSearch content

Link copied to clipboard
@get:Composable
val dockedShape: Shape

Default shape for a DockedSearchBar.

Link copied to clipboard
val Elevation: Dp
Link copied to clipboard
@get:Composable
val fullScreenShape: Shape

Default shape for a SearchBar in the expanded state.

Link copied to clipboard
@get:Composable
val fullScreenWindowInsets: WindowInsets

Default window insets used and consumed by ExpandedFullScreenSearchBar.

Link copied to clipboard

Default height for a search bar's input field, or a search bar in the unexpanded state.

Link copied to clipboard
@get:Composable
val inputFieldShape: Shape

Default shape for a search bar's input field, or a search bar in the unexpanded state.

Link copied to clipboard

Default shadow elevation for a search bar.

Link copied to clipboard

Default tonal elevation for a search bar.

Link copied to clipboard
@get:Composable
val windowInsets: WindowInsets

Default window insets for an AppBarWithSearch.

Functions

Link copied to clipboard
@Composable
fun appBarWithSearchColors(searchBarColors: SearchBarColors = colors(), scrolledSearchBarContainerColor: Color = ColorSchemeKeyTokens.SurfaceContainerHighest.value, appBarContainerColor: Color = AppBarTokens.ContainerColor.value, scrolledAppBarContainerColor: Color = AppBarTokens.OnScrollContainerColor.value, appBarNavigationIconColor: Color = AppBarTokens.LeadingIconColor.value, appBarActionIconColor: Color = AppBarTokens.TrailingIconColor.value): AppBarWithSearchColors

Creates an AppBarWithSearchColors that represents the different colors used in parts of the AppBarWithSearch.

Link copied to clipboard
@Composable
fun colors(containerColor: Color = SearchBarTokens.ContainerColor.value, dividerColor: Color = SearchViewTokens.DividerColor.value, inputFieldColors: TextFieldColors = inputFieldColors()): SearchBarColors

Creates a SearchBarColors that represents the different colors used in parts of the search bar.

Link copied to clipboard
@Composable
fun enterAlwaysSearchBarScrollBehavior(initialOffset: Float = 0.0f, initialOffsetLimit: Float = -Float.MAX_VALUE, initialContentOffset: Float = 0.0f, canScroll: () -> Boolean = { true }, snapAnimationSpec: AnimationSpec<Float> = MotionSchemeKeyTokens.DefaultEffects.value(), flingAnimationSpec: DecayAnimationSpec<Float> = rememberSplineBasedDecay(), reverseLayout: Boolean = false): SearchBarScrollBehavior

Returns a SearchBarScrollBehavior. A search bar that is set up with this behavior will immediately scroll upward off-screen when the content is pulled up, and will immediately appear when the content is pulled down.

Link copied to clipboard
@Composable
fun InputField(query: String, onQueryChange: (String) -> Unit, onSearch: (String) -> Unit, expanded: Boolean, onExpandedChange: (Boolean) -> Unit, modifier: Modifier = Modifier, enabled: Boolean = true, placeholder: @Composable () -> Unit? = null, leadingIcon: @Composable () -> Unit? = null, trailingIcon: @Composable () -> Unit? = null, colors: TextFieldColors = inputFieldColors(), interactionSource: MutableInteractionSource? = null)
@Composable
fun InputField(state: TextFieldState, onSearch: (String) -> Unit, expanded: Boolean, onExpandedChange: (Boolean) -> Unit, modifier: Modifier = Modifier, enabled: Boolean = true, readOnly: Boolean = false, textStyle: TextStyle = LocalTextStyle.current, placeholder: @Composable () -> Unit? = null, leadingIcon: @Composable () -> Unit? = null, trailingIcon: @Composable () -> Unit? = null, prefix: @Composable () -> Unit? = null, suffix: @Composable () -> Unit? = null, inputTransformation: InputTransformation? = null, outputTransformation: OutputTransformation? = null, scrollState: ScrollState = rememberScrollState(), shape: Shape = inputFieldShape, colors: TextFieldColors = inputFieldColors(), interactionSource: MutableInteractionSource? = null)
@Composable
fun InputField(textFieldState: TextFieldState, searchBarState: SearchBarState, onSearch: (String) -> Unit, modifier: Modifier = Modifier, enabled: Boolean = true, readOnly: Boolean = false, textStyle: TextStyle = LocalTextStyle.current, placeholder: @Composable () -> Unit? = null, leadingIcon: @Composable () -> Unit? = null, trailingIcon: @Composable () -> Unit? = null, prefix: @Composable () -> Unit? = null, suffix: @Composable () -> Unit? = null, inputTransformation: InputTransformation? = null, outputTransformation: OutputTransformation? = null, keyboardOptions: KeyboardOptions = KeyboardOptions.Default, lineLimits: TextFieldLineLimits = TextFieldLineLimits.SingleLine, scrollState: ScrollState = rememberScrollState(), shape: Shape = inputFieldShape, colors: TextFieldColors = inputFieldColors(), interactionSource: MutableInteractionSource? = null)

A text field to input a query in a search bar.

Link copied to clipboard
@Composable
fun inputFieldColors(focusedTextColor: Color = SearchBarTokens.InputTextColor.value, unfocusedTextColor: Color = SearchBarTokens.InputTextColor.value, disabledTextColor: Color = FilledTextFieldTokens.DisabledInputColor.value.copy( alpha = FilledTextFieldTokens.DisabledInputOpacity ), cursorColor: Color = FilledTextFieldTokens.CaretColor.value, selectionColors: TextSelectionColors = LocalTextSelectionColors.current, focusedLeadingIconColor: Color = SearchBarTokens.LeadingIconColor.value, unfocusedLeadingIconColor: Color = SearchBarTokens.LeadingIconColor.value, disabledLeadingIconColor: Color = FilledTextFieldTokens.DisabledLeadingIconColor.value.copy( alpha = FilledTextFieldTokens.DisabledLeadingIconOpacity ), focusedTrailingIconColor: Color = SearchBarTokens.TrailingIconColor.value, unfocusedTrailingIconColor: Color = SearchBarTokens.TrailingIconColor.value, disabledTrailingIconColor: Color = FilledTextFieldTokens.DisabledTrailingIconColor.value.copy( alpha = FilledTextFieldTokens.DisabledTrailingIconOpacity ), focusedPlaceholderColor: Color = SearchBarTokens.SupportingTextColor.value, unfocusedPlaceholderColor: Color = SearchBarTokens.SupportingTextColor.value, disabledPlaceholderColor: Color = FilledTextFieldTokens.DisabledInputColor.value.copy( alpha = FilledTextFieldTokens.DisabledInputOpacity ), focusedPrefixColor: Color = FilledTextFieldTokens.InputPrefixColor.value, unfocusedPrefixColor: Color = FilledTextFieldTokens.InputPrefixColor.value, disabledPrefixColor: Color = FilledTextFieldTokens.InputPrefixColor.value.copy( alpha = FilledTextFieldTokens.DisabledInputOpacity ), focusedSuffixColor: Color = FilledTextFieldTokens.InputSuffixColor.value, unfocusedSuffixColor: Color = FilledTextFieldTokens.InputSuffixColor.value, disabledSuffixColor: Color = FilledTextFieldTokens.InputSuffixColor.value.copy( alpha = FilledTextFieldTokens.DisabledInputOpacity ), focusedContainerColor: Color = Color.Transparent, unfocusedContainerColor: Color = Color.Transparent, disabledContainerColor: Color = Color.Transparent): TextFieldColors

Creates a TextFieldColors that represents the different colors used in the search bar input field in different states.