ExposedDropdownMenuBoxScope



Scope for ExposedDropdownMenuBox.

Summary

Protected constructors

android

Public functions

Unit
@Composable
ExposedDropdownMenu(
    expanded: Boolean,
    onDismissRequest: () -> Unit,
    modifier: Modifier,
    scrollState: ScrollState,
    matchTextFieldWidth: Boolean,
    shape: Shape,
    containerColor: Color,
    tonalElevation: Dp,
    shadowElevation: Dp,
    border: BorderStroke?,
    content: @Composable ColumnScope.() -> Unit
)

Popup which contains content for Exposed Dropdown Menu.

android
Unit
@Composable
ExposedDropdownMenu(
    expanded: Boolean,
    onDismissRequest: () -> Unit,
    modifier: Modifier,
    scrollState: ScrollState,
    focusable: Boolean,
    matchTextFieldWidth: Boolean,
    shape: Shape,
    containerColor: Color,
    tonalElevation: Dp,
    shadowElevation: Dp,
    border: BorderStroke?,
    content: @Composable ColumnScope.() -> Unit
)

This function is deprecated. The `focusable` parameter is unused.

android
abstract Modifier
Modifier.exposedDropdownSize(matchTextFieldWidth: Boolean)

Modifier which should be applied to a menu placed inside the ExposedDropdownMenuBoxScope.

android
Modifier

This function is deprecated. Use overload that takes MenuAnchorType and enabled parameters

android
abstract Modifier

Modifier which should be applied to an element inside the ExposedDropdownMenuBoxScope, typically a text field or an icon within the text field.

android

Protected constructors

ExposedDropdownMenuBoxScope

protected ExposedDropdownMenuBoxScope()

Public functions

ExposedDropdownMenu

@Composable
fun ExposedDropdownMenu(
    expanded: Boolean,
    onDismissRequest: () -> Unit,
    modifier: Modifier = Modifier,
    scrollState: ScrollState = rememberScrollState(),
    matchTextFieldWidth: Boolean = true,
    shape: Shape = MenuDefaults.shape,
    containerColor: Color = MenuDefaults.containerColor,
    tonalElevation: Dp = MenuDefaults.TonalElevation,
    shadowElevation: Dp = MenuDefaults.ShadowElevation,
    border: BorderStroke? = null,
    content: @Composable ColumnScope.() -> Unit
): Unit

Popup which contains content for Exposed Dropdown Menu. Should be used inside the content of ExposedDropdownMenuBox.

Parameters
expanded: Boolean

whether the menu is expanded

onDismissRequest: () -> Unit

called when the user requests to dismiss the menu, such as by tapping outside the menu's bounds

modifier: Modifier = Modifier

the Modifier to be applied to this menu

scrollState: ScrollState = rememberScrollState()

a ScrollState used by the menu's content for items vertical scrolling

matchTextFieldWidth: Boolean = true

whether the menu's width should be forcefully constrained to match the width of the text field to which it's attached.

shape: Shape = MenuDefaults.shape

the shape of the menu

containerColor: Color = MenuDefaults.containerColor

the container color of the menu

tonalElevation: Dp = MenuDefaults.TonalElevation

when containerColor is ColorScheme.surface, a translucent primary color overlay is applied on top of the container. A higher tonal elevation value will result in a darker color in light theme and lighter color in dark theme. See also: Surface.

shadowElevation: Dp = MenuDefaults.ShadowElevation

the elevation for the shadow below the menu

border: BorderStroke? = null

the border to draw around the container of the menu. Pass null for no border.

content: @Composable ColumnScope.() -> Unit

the content of the menu

ExposedDropdownMenu

@Composable
fun ExposedDropdownMenu(
    expanded: Boolean,
    onDismissRequest: () -> Unit,
    modifier: Modifier = Modifier,
    scrollState: ScrollState = rememberScrollState(),
    focusable: Boolean = true,
    matchTextFieldWidth: Boolean = true,
    shape: Shape = MenuDefaults.shape,
    containerColor: Color = MenuDefaults.containerColor,
    tonalElevation: Dp = MenuDefaults.TonalElevation,
    shadowElevation: Dp = MenuDefaults.ShadowElevation,
    border: BorderStroke? = null,
    content: @Composable ColumnScope.() -> Unit
): Unit

exposedDropdownSize

abstract fun Modifier.exposedDropdownSize(matchTextFieldWidth: Boolean = true): Modifier

Modifier which should be applied to a menu placed inside the ExposedDropdownMenuBoxScope. It will set constraints on the width and height of the menu so it will not overlap the text field or software keyboard.

ExposedDropdownMenu applies this modifier automatically, so this is only needed when using custom menu components.

Parameters
matchTextFieldWidth: Boolean = true

whether the menu's width should be forcefully constrained to match the width of the text field to which it's attached.

menuAnchor

fun Modifier.menuAnchor(): Modifier

menuAnchor

abstract fun Modifier.menuAnchor(type: MenuAnchorType, enabled: Boolean = true): Modifier

Modifier which should be applied to an element inside the ExposedDropdownMenuBoxScope, typically a text field or an icon within the text field. It's responsible for expanding and collapsing the menu on click, applying semantics to the component, and requesting focus.

Parameters
type: MenuAnchorType

the type of element that is anchoring the menu. See MenuAnchorType.

enabled: Boolean = true

controls the enabled state. When false, the component will not expand or collapse the menu in response to user input, and menu semantics will be invisible to accessibility services. Note that this value only controls interactions with the menu. It does not affect the enabled state of other kinds of interactions, such as TextField's enabled parameter.