Dropdown
A menu that floats under its trigger.
It flips above the trigger when there's no room below. A click outside, picking an item, Escape, or opening another menu closes it.
Installation
bash
shellui-native add dropdown
Platforms: MAUI · Avalonia. Also installs dropdown-trigger, dropdown-content, dropdown-item, element-extensions, icon.
Usage
Basic
<ui:Dropdown>
<ui:DropdownTrigger>
<ui:Button Text="Shewart" Icon="ChevronDown" IconPosition="Right" Variant="Outline" />
</ui:DropdownTrigger>
<ui:DropdownContent>
<ui:DropdownItem Text="Profile" Icon="User" Clicked="OnProfile" />
<ui:DropdownItem Text="Settings" Icon="Settings" Clicked="OnSettings" />
<ui:DropdownItem Text="Log out" Icon="LogOut" Clicked="OnLogOut" />
</ui:DropdownContent>
</ui:Dropdown><ui:Dropdown>
<ui:DropdownTrigger>
<ui:Button Text="Shewart" Icon="ChevronDown" IconPosition="Right" Variant="Outline" />
</ui:DropdownTrigger>
<ui:DropdownContent>
<ui:DropdownItem Text="Profile" Icon="User" Clicked="OnProfile" />
<ui:DropdownItem Text="Settings" Icon="Settings" Clicked="OnSettings" />
<ui:DropdownItem Text="Log out" Icon="LogOut" Clicked="OnLogOut" />
</ui:DropdownContent>
</ui:Dropdown>Not available on yet
MAUI and Avalonia
MAUI also keeps ToggleAsync() and CloseAsync() for older code; on Avalonia use Toggle() and Close().
API
Dropdown
XAML children go to Items on Avalonia.
| Property | Type | Default | Description |
|---|---|---|---|
IsOpen |
bool |
false |
Whether it's open. Two-way bindable. |
| Event | Arguments | Description |
|---|---|---|
IsOpenChanged |
bool |
Opened or closed. |
| Method | Description |
|---|---|
ToggleAsync() |
Kept for compatibility with earlier versions. MAUI only. |
CloseAsync() |
MAUI only. |
SetOpen(bool value) |
Opens or closes it. |
Toggle() |
Opens it if closed, closes it if open. |
Close() |
Closes it. |
DropdownTrigger
| Method | Description |
|---|---|
Activate() |
Does what pressing it does. |
ShellTriggerView.ActivateAncestor(Element from) |
Called by interactive children (Button) after they handle a click. |
DropdownContent
XAML children go to Items on Avalonia and Children on MAUI.
No properties of its own.
DropdownItem
| Property | Type | Default | Description |
|---|---|---|---|
Text |
string |
— | Text shown by the component. |
Icon |
IconName |
None |
Lucide icon from IconName; None for no icon. |
| Event | Arguments | Description |
|---|---|---|
Clicked |
— | Clicked or tapped (or Enter / Space with keyboard focus). |
| Method | Description |
|---|---|
Press() |
Picks the item in code, as a click or Enter/Space would. Avalonia only. |