Skip to content

WindowDropdownMenu

WindowDropdownMenu is a BasicComponent wrapper that opens a WindowDropdownPopup (rendered at window level via Dialog) when clicked. Unlike WindowDropdownPreference, it does not own a single selection index — selection state lives entirely on each DropdownItem's selected and onClick. Use it for action menus, multi-select menus, or any case where the items in a popup do not share one mutually exclusive choice.

Import

kotlin
import top.yukonga.miuix.kmp.menu.WindowDropdownMenu
import top.yukonga.miuix.kmp.basic.DropdownEntry
import top.yukonga.miuix.kmp.basic.DropdownItem

Basic Usage

Wrap a single DropdownEntry to render a basic dropdown menu row. No Scaffold is required:

kotlin
var selectedIndex by remember { mutableStateOf(0) }
val entry = DropdownEntry(
    items = listOf("Option 1", "Option 2", "Option 3").mapIndexed { index, text ->
        DropdownItem(
            text = text,
            selected = selectedIndex == index,
            onClick = { selectedIndex = index },
        )
    }
)

WindowDropdownMenu(
    title = "Dropdown Menu",
    entry = entry
)

Grouped Menu

Pass a List<DropdownEntry> to render multiple groups separated by dividers. By default, collapseOnSelection is entries.size <= 1, so multi-group menus stay open after each selection.

kotlin
var sizeIndex by remember { mutableStateOf(0) }
var colorIndex by remember { mutableStateOf(0) }
val entries = listOf(
    DropdownEntry(
        items = listOf("Small", "Medium").mapIndexed { index, text ->
            DropdownItem(text = text, selected = sizeIndex == index, onClick = { sizeIndex = index })
        }
    ),
    DropdownEntry(
        items = listOf("Red", "Green", "Blue").mapIndexed { index, text ->
            DropdownItem(text = text, selected = colorIndex == index, onClick = { colorIndex = index })
        }
    )
)

WindowDropdownMenu(
    title = "Grouped Menu",
    entries = entries,
    collapseOnSelection = false
)

Multi Select

Selection state lives on DropdownItem.selected, so multiple items can be selected simultaneously by toggling each item's value from onClick.

kotlin
var selected by remember { mutableStateOf(setOf("A1", "B2")) }
val entries = listOf(
    DropdownEntry(
        items = listOf("A1", "A2").map { text ->
            DropdownItem(
                text = text,
                selected = text in selected,
                onClick = {
                    selected = if (text in selected) selected - text else selected + text
                }
            )
        }
    ),
    DropdownEntry(
        items = listOf("B1", "B2", "B3").map { text ->
            DropdownItem(
                text = text,
                selected = text in selected,
                onClick = {
                    selected = if (text in selected) selected - text else selected + text
                }
            )
        }
    )
)

WindowDropdownMenu(
    title = "Multi Select Menu",
    entries = entries,
    collapseOnSelection = false
)

Observe Expanded State

kotlin
var expanded by remember { mutableStateOf(false) }
val entry = DropdownEntry(
    items = listOf("Option 1", "Option 2", "Option 3").map { DropdownItem(text = it) }
)

WindowDropdownMenu(
    title = "Observe Expanded",
    summary = if (expanded) "Expanded" else "Collapsed",
    entry = entry,
    onExpandedChange = { expanded = it }
)

Component States

Disabled State

kotlin
WindowDropdownMenu(
    title = "Disabled Menu",
    summary = "This menu is currently unavailable",
    entry = DropdownEntry(items = listOf(DropdownItem(text = "Option 1"))),
    enabled = false
)

The menu is also implicitly disabled when no DropdownEntry contains any items.

Properties

WindowDropdownMenu Properties (Entries Overload)

Property NameTypeDescriptionDefault ValueRequired
entriesList<DropdownEntry>Dropdown entry groups separated by dividers-Yes
titleStringTitle of the menu row-Yes
modifierModifierModifier applied to the componentModifierNo
titleColorBasicComponentColorsTitle text color configurationBasicComponentDefaults.titleColor()No
summaryString?Summary description of the menunullNo
summaryColorBasicComponentColorsSummary text color configurationBasicComponentDefaults.summaryColor()No
dropdownColorsDropdownColorsColor configuration for dropdown itemsDropdownDefaults.dropdownColors()No
startAction@Composable (() -> Unit)?Custom start side contentnullNo
bottomAction@Composable (() -> Unit)?Custom bottom side contentnullNo
insideMarginPaddingValuesInternal content paddingBasicComponentDefaults.InsideMarginNo
maxHeightDp?Maximum height of the dropdown popupnullNo
enabledBooleanWhether component is interactivetrueNo
collapseOnSelectionBooleanWhether to close the popup after each selectionentries.size <= 1No
onExpandedChange((Boolean) -> Unit)?Callback when the expanded state changesnullNo

Entry Overload Properties

Property NameTypeDescriptionDefault ValueRequired
entryDropdownEntrySingle dropdown entry group-Yes
collapseOnSelectionBooleanWhether to close the popup after selectiontrueNo

All other parameters are identical to the entries overload above.

Property NameTypeDescriptionDefault ValueRequired
itemsList<DropdownItem>Items shown in this dropdown group-Yes
enabledBooleanWhether this group is enabled. False disables all items; true still respects each item's enabled statetrueNo
Property NameTypeDescriptionDefault ValueRequired
textStringText shown for the item-Yes
enabledBooleanWhether the item can be clicked. Disabled items are graytrueNo
selectedBooleanWhether the item is selectedfalseNo
onClick(() -> Unit)?Callback invoked when the item is clickednullNo
icon@Composable ((Modifier) -> Unit)?Icon shown before the item textnullNo
summaryString?Summary text shown below the item textnullNo
childrenList<DropdownItem>?Optional submenu items; cascading variants onlynullNo
Property NameTypeDescription
contentColorColorColor of the option title
summaryColorColorColor of the option summary
containerColorColorBackground color of the option
selectedContentColorColorTitle color of the selected option
selectedSummaryColorColorSummary color of the selected option
selectedContainerColorColorBackground color of the selected option
selectedIndicatorColorColorColor of the selected indicator icon

Changelog

Released under the Apache-2.0 License