Skip to content
Navigation

Menu

Dropdown menus and exposed dropdown selection

Menus display a list of choices on a temporary surface. A DropdownMenu anchors to a trigger such as a button, while an ExposedDropdownMenuBox pairs a text field with a menu so people can pick a value.

Menu demos rendered in Compose Playground
Pixel-accurate preview · light theme

Examples

02

Exposed dropdown

A read-only text field reveals a menu of selectable values.

Kotlin
val options = listOf("Low", "Medium", "High")
var expanded by remember { mutableStateOf(false) }
var selected by remember { mutableStateOf(options[0]) }
ExposedDropdownMenuBox(expanded = expanded, onExpandedChange = { expanded = it }) {
    OutlinedTextField(
        value = selected,
        onValueChange = {},
        readOnly = true,
        label = { Text("Priority") },
        trailingIcon = { ExposedDropdownMenuDefaults.TrailingIcon(expanded) },
        modifier = Modifier.menuAnchor()
    )
    ExposedDropdownMenu(expanded = expanded, onDismissRequest = { expanded = false }) {
        options.forEach { option ->
            DropdownMenuItem(
                text = { Text(option) },
                onClick = { selected = option; expanded = false }
            )
        }
    }
}