androidx.compose.material3
DropdownMenu
Composable function
A menu shows a list of choices on top of the screen, usually opened from a "more" button.
The menu opens next to its parent. Put the button and the DropdownMenu in the same Box.
The menu is shown while expanded is true. You keep that in a variable.

var expanded by remember { mutableStateOf(true) }
// The outer Box only gives the picture room for the open menu.
Box(Modifier.size(260.dp, 240.dp), contentAlignment = Alignment.TopEnd) {
// The menu opens next to its parent: put the button and the menu in one Box.
Box {
IconButton(onClick = { expanded = true }) { Icon(Icons.Filled.MoreVert, "More options") }
DropdownMenu(expanded = expanded, onDismissRequest = { expanded = false }) {
DropdownMenuItem(text = { Text("Edit") }, onClick = { expanded = false })
DropdownMenuItem(text = { Text("Share") }, onClick = { expanded = false })
DropdownMenuItem(text = { Text("Delete") }, onClick = { expanded = false })
}
}
}

Box(Modifier.size(260.dp, 300.dp)) {
Box {
IconButton(onClick = {}) { Icon(Icons.Filled.MoreVert, "More options") }
DropdownMenu(expanded = true, onDismissRequest = {}) {
DropdownMenuItem(
text = { Text("Edit") },
onClick = {},
leadingIcon = { Icon(Icons.Filled.Edit, null) },
)
DropdownMenuItem(
text = { Text("Share") },
onClick = {},
leadingIcon = { Icon(Icons.Filled.Share, null) },
trailingIcon = { Text("Ctrl+S") },
)
HorizontalDivider()
DropdownMenuItem(
text = { Text("Delete") },
onClick = {},
leadingIcon = { Icon(Icons.Filled.Delete, null) },
enabled = false,
)
}
}
}
Expressive menus can split items into groups: put DropdownMenuGroups inside a DropdownMenuPopup.
To pick a value in a form, use an ExposedDropdownMenuBox instead.
Parameters
@Composable
fun DropdownMenu(
expanded: Boolean,
onDismissRequest: () -> Unit,
modifier: Modifier = Modifier,
offset: DpOffset = DpOffset(0.dp, 0.dp),
scrollState: ScrollState = rememberScrollState(),
properties: PopupProperties = DefaultMenuProperties,
shape: Shape = MenuDefaults.shape,
containerColor: Color = MenuDefaults.containerColor,
tonalElevation: Dp = MenuDefaults.TonalElevation,
shadowElevation: Dp = MenuDefaults.ShadowElevation,
border: BorderStroke? = null,
content: @Composable ColumnScope.() -> Unit,
)
expanded: BooleanRequired
expanded: BooleanRequiredWhether the menu is open. Pass your state here.
onDismissRequest: () -> UnitRequired
onDismissRequest: () -> UnitRequiredCalled when the user taps outside the menu or presses back. Set your state to false here.
modifier: ModifierOptional
modifier: ModifierOptionalDefault: Modifier
Changes size, padding, or position. See the Modifier guide.
scrollState: ScrollStateOptional
scrollState: ScrollStateOptionalDefault: rememberScrollState()
Controls scrolling when the menu is too long for the screen.
properties: PopupPropertiesOptional
properties: PopupPropertiesOptionalDefault: DefaultMenuProperties
Popup options, like whether the menu takes focus.
shape: ShapeOptional
shape: ShapeOptionalDefault: MenuDefaults.shape
Sets the outline of the menu or item. See the Shapes guide.
containerColor: ColorOptional
containerColor: ColorOptionalDefault: MenuDefaults.containerColor
The background color of the menu.
tonalElevation: DpOptional
tonalElevation: DpOptionalDefault: MenuDefaults.TonalElevation
Tints the menu background a little toward the primary color.
shadowElevation: DpOptional
shadowElevation: DpOptionalDefault: MenuDefaults.ShadowElevation
The size of the shadow under the menu.
border: BorderStroke?Optional
border: BorderStroke?OptionalDefault: null
Draws an outline around the menu.
content: @Composable ColumnScope.() -> UnitRequired
content: @Composable ColumnScope.() -> UnitRequiredThe items. Add one DropdownMenuItem each. Items are placed in a Column. Add a HorizontalDivider between groups.