New Compose Multiplatform components arrived on Composables UICheck it out →

Component in Material Compose

CursorDropdownMenu

Desktop

A [CursorDropdownMenu] behaves similarly to [Popup] and will use the current position of the mouse cursor to position itself on screen.

The [content] of a [CursorDropdownMenu] will typically be [DropdownMenuItem]s, as well as custom content. Using [DropdownMenuItem]s will result in a menu that matches the Material specification for menus.

Last updated:

Installation

dependencies {
   implementation("androidx.compose.material:material:1.7.0-beta04")
}

Overloads

@Composable
@Deprecated(
    level = DeprecationLevel.HIDDEN,
    replaceWith = ReplaceWith(
        expression = "CursorDropdownMenu(expanded,onDismissRequest, focusable, modifier, " +
            "rememberScrollState(), content)",
        "androidx.compose.foundation.rememberScrollState"
    ),
    message = "Replaced by a CursorDropdownMenu function with a ScrollState parameter"

fun CursorDropdownMenu(
    expanded: Boolean,
    onDismissRequest: () -> Unit,
    focusable: Boolean = true,
    modifier: Modifier = Modifier,
    content: @Composable ColumnScope.() -> Unit
)

Parameters

namedescription
expandedWhether the menu is currently open and visible to the user
onDismissRequestCalled when the user requests to dismiss the menu, such as by tapping outside the menu's bounds
focusableSets the ability for the menu to capture focus
modifierThe modifier for this layout.
contentThe content lambda.
@Composable
fun CursorDropdownMenu(
    expanded: Boolean,
    onDismissRequest: () -> Unit,
    focusable: Boolean = true,
    modifier: Modifier = Modifier,
    scrollState: ScrollState = rememberScrollState(),
    content: @Composable ColumnScope.() -> Unit
)

Parameters

namedescription
expandedWhether the menu is currently open and visible to the user
onDismissRequestCalled when the user requests to dismiss the menu, such as by tapping outside the menu's bounds
focusableWhether the dropdown can capture focus
modifier[Modifier] to be applied to the menu's content
scrollStatea [ScrollState] to used by the menu's content for items vertical scrolling
contentthe content of this dropdown menu, typically a [DropdownMenuItem]