{% setvar book_path %}/reference/androidx/_book.yaml{% endsetvar %} {% include "_shared/_reference-head-tags.html" %}

SearchBarDefaults

@ExperimentalMaterial3Api
public static class SearchBarDefaults


Defaults used in SearchBar and DockedSearchBar.

Summary

Public fields

static @NonNull SearchBarDefaults

Public methods

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

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

final @NonNull Shape

Default shape for a DockedSearchBar.

final @NonNull Dp
final @NonNull Shape

Default shape for a SearchBar in the active state.

final @NonNull Dp

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

final @NonNull Shape

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

final @NonNull Dp

Default shadow elevation for a search bar.

final @NonNull Dp

Default tonal elevation for a search bar.

final @NonNull WindowInsets

Default window insets for a SearchBar.

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

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

Public fields

INSTANCE

public static @NonNull SearchBarDefaults INSTANCE

Public methods

colors

@Composable
public final @NonNull SearchBarColors colors(
    @NonNull Color containerColor,
    @NonNull Color dividerColor,
    @NonNull TextFieldColors inputFieldColors
)

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

Parameters
@NonNull Color containerColor

the container color of the search bar

@NonNull Color dividerColor

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

@NonNull TextFieldColors inputFieldColors

the colors of the input field

getDockedShape

@Composable
public final @NonNull Shape getDockedShape()

Default shape for a DockedSearchBar.

getElevation

public final @NonNull Dp getElevation()

getFullScreenShape

@Composable
public final @NonNull Shape getFullScreenShape()

Default shape for a SearchBar in the active state.

getInputFieldHeight

public final @NonNull Dp getInputFieldHeight()

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

getInputFieldShape

@Composable
public final @NonNull Shape getInputFieldShape()

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

getShadowElevation

public final @NonNull Dp getShadowElevation()

Default shadow elevation for a search bar.

getTonalElevation

public final @NonNull Dp getTonalElevation()

Default tonal elevation for a search bar.

getWindowInsets

@Composable
public final @NonNull WindowInsets getWindowInsets()

Default window insets for a SearchBar.

inputFieldColors

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

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
@NonNull Color focusedTextColor

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

@NonNull Color unfocusedTextColor

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

@NonNull Color disabledTextColor

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

@NonNull Color cursorColor

the cursor color for this input field

@NonNull TextSelectionColors selectionColors

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

@NonNull Color focusedLeadingIconColor

the leading icon color for this input field when focused

@NonNull Color unfocusedLeadingIconColor

the leading icon color for this input field when not focused

@NonNull Color disabledLeadingIconColor

the leading icon color for this input field when disabled

@NonNull Color focusedTrailingIconColor

the trailing icon color for this input field when focused

@NonNull Color unfocusedTrailingIconColor

the trailing icon color for this input field when not focused

@NonNull Color disabledTrailingIconColor

the trailing icon color for this input field when disabled

@NonNull Color focusedPlaceholderColor

the placeholder color for this input field when focused

@NonNull Color unfocusedPlaceholderColor

the placeholder color for this input field when not focused

@NonNull Color disabledPlaceholderColor

the placeholder color for this input field when disabled