Popup Menu
fun PopupMenu(popupMenuState: PopupMenuState, appearance: PopupMenuAppearance = PopupMenuAppearance.default(), onDismiss: () -> Unit = {})
A popup menu that can be shown at a given offset. The menu items are shown in a row, and if there are more items than can fit in the row, a "more" button is shown. When the "more" button is clicked, the remaining items are shown in a dropdown. The menu will not exceed the bounds of its parent container
Usage:
var popupState by remember { mutableStateOf(PopupMenuState()) }
Box(
modifier =
Modifier
.fillMaxSize()
.pointerInput(Unit) {
detectTapGestures(
onLongPress = { offset ->
val menuItems =
listOf(
PopupMenuItemImpl("item 1") { action1() },
PopupMenuItemImpl("item 2") { action2() },
PopupMenuItemImpl("item 3") { action3() },
PopupMenuItemImpl("item 4") { action4() }
)
popupState = PopupMenuState.shownAt(offset, menuItems)
}
)
}
) {
PopupMenu(
popupStatus,
dismiss = { popupStatus = PopupMenuState.hidden() }
)
}Content copied to clipboard