SearchBarDefaults


Defaults used in SearchBar and DockedSearchBar.

Summary

Public functions

SearchBarColors
@Composable
colors(
    containerColor: Color,
    dividerColor: Color,
    inputFieldColors: TextFieldColors
)

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

android
TextFieldColors
@Composable
inputFieldColors(
    focusedTextColor: Color,
    unfocusedTextColor: Color,
    disabledTextColor: Color,
    cursorColor: Color,
    selectionColors: TextSelectionColors,
    focusedLeadingIconColor: Color,
    unfocusedLeadingIconColor: Color,
    disabledLeadingIconColor: Color,
    focusedTrailingIconColor: Color,
    unfocusedTrailingIconColor: Color,
    disabledTrailingIconColor: Color,
    focusedPlaceholderColor: Color,
    unfocusedPlaceholderColor: Color,
    disabledPlaceholderColor: Color
)

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

android

Public properties

Dp

This property is deprecated. Renamed to TonalElevation.

android
Dp

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

android
Dp

Default shadow elevation for a search bar.

android
Dp

Default tonal elevation for a search bar.

android
Shape

Default shape for a DockedSearchBar.

android
Shape

Default shape for a SearchBar in the active state.

android
Shape

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

android
WindowInsets

Default window insets for a SearchBar.

android

Public functions

colors

@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 in different states.

Parameters
containerColor: Color = SearchBarTokens.ContainerColor.value

the container color of the search bar

dividerColor: Color = SearchViewTokens.DividerColor.value

the color of the divider between the input field and the search results

inputFieldColors: TextFieldColors = inputFieldColors()

the colors of the input field

inputFieldColors

@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)
): TextFieldColors

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

Only a subset of the full list of TextFieldColors parameters are used in the input field. All other parameters have no effect.

Parameters
focusedTextColor: Color = SearchBarTokens.InputTextColor.value

the color used for the input text of this input field when focused

unfocusedTextColor: Color = SearchBarTokens.InputTextColor.value

the color used for the input text of this input field when not focused

disabledTextColor: Color = FilledTextFieldTokens.DisabledInputColor.value .copy(alpha = FilledTextFieldTokens.DisabledInputOpacity)

the color used for the input text of this input field when disabled

cursorColor: Color = FilledTextFieldTokens.CaretColor.value

the cursor color for this input field

selectionColors: TextSelectionColors = LocalTextSelectionColors.current

the colors used when the input text of this input field is selected

focusedLeadingIconColor: Color = SearchBarTokens.LeadingIconColor.value

the leading icon color for this input field when focused

unfocusedLeadingIconColor: Color = SearchBarTokens.LeadingIconColor.value

the leading icon color for this input field when not focused

disabledLeadingIconColor: Color = FilledTextFieldTokens.DisabledLeadingIconColor .value.copy(alpha = FilledTextFieldTokens.DisabledLeadingIconOpacity)

the leading icon color for this input field when disabled

focusedTrailingIconColor: Color = SearchBarTokens.TrailingIconColor.value

the trailing icon color for this input field when focused

unfocusedTrailingIconColor: Color = SearchBarTokens.TrailingIconColor.value

the trailing icon color for this input field when not focused

disabledTrailingIconColor: Color = FilledTextFieldTokens.DisabledTrailingIconColor .value.copy(alpha = FilledTextFieldTokens.DisabledTrailingIconOpacity)

the trailing icon color for this input field when disabled

focusedPlaceholderColor: Color = SearchBarTokens.SupportingTextColor.value

the placeholder color for this input field when focused

unfocusedPlaceholderColor: Color = SearchBarTokens.SupportingTextColor.value

the placeholder color for this input field when not focused

disabledPlaceholderColor: Color = FilledTextFieldTokens.DisabledInputColor.value .copy(alpha = FilledTextFieldTokens.DisabledInputOpacity)

the placeholder color for this input field when disabled

Public properties

Elevation

val ElevationDp

InputFieldHeight

val InputFieldHeightDp

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

ShadowElevation

val ShadowElevationDp

Default shadow elevation for a search bar.

TonalElevation

val TonalElevationDp

Default tonal elevation for a search bar.

dockedShape

val dockedShapeShape

Default shape for a DockedSearchBar.

fullScreenShape

val fullScreenShapeShape

Default shape for a SearchBar in the active state.

inputFieldShape

val inputFieldShapeShape

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

windowInsets

val windowInsetsWindowInsets

Default window insets for a SearchBar.