Skip to content

Dropdown

@Composable



fun <T> Dropdown(
    options: List<DropdownOption<T>>, 
    selected: T?, 
    onSelected: (T) -> Unit, 
    modifier: Modifier = Modifier, 
    placeholder: Component = Component.literal("Select..."), 
    enabled: Boolean = true, 
    width: Int = 120, 
    maxVisibleOptions: Int = 5
)

A single-choice select: a trigger showing the current selection, which opens into a list.

The open list is hosted in a layer of its own, anchored under the trigger. That is what lets it hang outside whatever contains the dropdown: an inline list is drawn inside its ancestors' scissors, so one inside a fixed-height page or a net.kernelpanicsoft.archie.gui.composables.containers.Scrollable was simply cut off at that boundary - and no amount of z-index fixes that, because clipping happens while drawing rather than being resolved by depth.

Falls back to expanding inline where there is no layer manager to host the list, which keeps the component usable on a plain screen at the cost of the clipping described above.

Clicking anywhere outside the open list closes it without changing the selection.

Parameters

  • selected: The currently chosen value, or null to show placeholder.

  • onSelected: Invoked with the newly picked value. The list closes itself either way.

  • enabled: When false the trigger is dead and the list cannot be opened.