ExposedDropdownMenuBoxScope


Scope for ExposedDropdownMenuBox.

Summary

Protected constructors

Cmn

Public functions

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

Popup which contains content for Exposed Dropdown Menu.

Cmn
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.

Cmn
abstract Modifier

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

Cmn
Modifier

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

Cmn
abstract Modifier
Modifier.menuAnchor(
    type: ExposedDropdownMenuAnchorType,
    enabled: Boolean
)

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

Cmn

Protected constructors

ExposedDropdownMenuBoxScope

protected ExposedDropdownMenuBoxScope()

Public functions

ExposedDropdownMenu

@Composable
fun ExposedDropdownMenu(
    expanded: Boolean,
    onDismissRequest: () -> Unit,
    modifier: Modifier = Modifier,
    scrollState: ScrollState = rememberScrollState(),
    matchAnchorWidth: 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

matchAnchorWidth: 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(matchAnchorWidth: 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
matchAnchorWidth: 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
abstract fun Modifier.menuAnchor(
    type: ExposedDropdownMenuAnchorType,
    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 requesting focus, and if enabled, expanding/collapsing the menu on click and applying semantics.

Parameters
type: ExposedDropdownMenuAnchorType

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

enabled: Boolean = true

whether controlling the menu via this anchor is enabled. 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.