androidx.compose.material3
ExposedDropdownMenuBoxExperimental
Composable function
An exposed drop-down menu is a text field with a menu under it. Use it in forms to pick one value from a list, like a size or a country.
It has three pieces, all inside the box:
- A text field with
Modifier.menuAnchor(...). The menu opens under it. ExposedDropdownMenuDefaults.TrailingIconto show the arrow.ExposedDropdownMenuwith oneDropdownMenuItemper option.
menuAnchor and ExposedDropdownMenu only exist inside the box.

val options = listOf("Small", "Medium", "Large")
var expanded by remember { mutableStateOf(true) }
var choice by remember { mutableStateOf(options[1]) }
Box(Modifier.size(300.dp, 300.dp)) {
ExposedDropdownMenuBox(expanded = expanded, onExpandedChange = { expanded = it }) {
OutlinedTextField(
value = choice,
onValueChange = {},
readOnly = true,
label = { Text("Size") },
trailingIcon = { ExposedDropdownMenuDefaults.TrailingIcon(expanded = expanded) },
modifier = Modifier.menuAnchor(ExposedDropdownMenuAnchorType.PrimaryNotEditable),
)
ExposedDropdownMenu(expanded = expanded, onDismissRequest = { expanded = false }) {
options.forEach { option ->
DropdownMenuItem(text = { Text(option) }, onClick = { choice = option; expanded = false })
}
}
}
}
Use ExposedDropdownMenuAnchorType.PrimaryNotEditable with a readOnly field to pick from a fixed list. Use PrimaryEditable if the user can also type to filter the list.
ParametersExperimental
@Composable
fun ExposedDropdownMenuBox(
expanded: Boolean,
onExpandedChange: (Boolean) -> Unit,
modifier: Modifier = Modifier,
content: @Composable ExposedDropdownMenuBoxScope.() -> Unit,
)
expanded: BooleanRequired
expanded: BooleanRequiredWhether the menu is open. Pass your state here.
onExpandedChange: (Boolean) -> UnitRequired
onExpandedChange: (Boolean) -> UnitRequiredCalled when the user clicks the field. Set your state to the new value here.
modifier: ModifierOptional
modifier: ModifierOptionalDefault: Modifier
Changes size, padding, or position. See the Modifier guide.
content: @Composable ExposedDropdownMenuBoxScope.() -> UnitRequired
content: @Composable ExposedDropdownMenuBoxScope.() -> UnitRequiredThe text field and the menu. See the three pieces above.