Dropdown Menu

Dropdown Menu

Displays a menu of actions or options triggered by a button.

Basic Dropdown Menu

A simple dropdown menu with items.

With Icons

Add Lucide icons to menu items for better visual hierarchy.

With Labels and Separators

Organize menu items with labels and visual separators.

Grouped Items

Group related menu items together.

With Keyboard Shortcuts

Display keyboard shortcuts alongside menu items (visual only).

Functional Keyboard Shortcuts

Keyboard shortcuts that actually work! Press the shortcut keys anywhere on this page (even when the menu is closed) to trigger the action.

Try these shortcuts (even with the menu closed):

Ctrl+Shift+N New File
Ctrl+O Open
Ctrl+S Save
Ctrl+Shift+S Save As

Usage with KeyboardShortcutService:

@inject IKeyboardShortcutService KeyboardShortcuts
@implements IAsyncDisposable

@code {
    private IDisposable? _shortcutNew;

    protected override async Task OnAfterRenderAsync(bool firstRender)
    {
        if (firstRender)
        {
            _shortcutNew = await KeyboardShortcuts.RegisterAsync(
                "Ctrl+Shift+N", HandleNewFile);
        }
    }

    private Task HandleNewFile()
    {
        // Handle the shortcut action
        return Task.CompletedTask;
    }

    public ValueTask DisposeAsync()
    {
        _shortcutNew?.Dispose();
        return ValueTask.CompletedTask;
    }
}

Alignment Options

Control how the dropdown aligns relative to its trigger (Start, Center, End). Test with small icon buttons to see alignment clearly.

Disabled Items

Menu items can be disabled to prevent interaction.

AsChild Pattern

Use AsChild to compose triggers with your own styled Button components.

Without AsChild

DropdownMenuTrigger renders its own button with inline classes.

With AsChild

Button component receives trigger behavior via TriggerContext.

Code Example:

<DropdownMenu>
    <DropdownMenuTrigger AsChild>
        <Button Variant="ButtonVariant.Outline">
            Actions
            <LucideIcon Name="chevron-down" Size="16" />
        </Button>
    </DropdownMenuTrigger>
    <DropdownMenuContent>
        <DropdownMenuItem>Edit</DropdownMenuItem>
        <DropdownMenuItem>Delete</DropdownMenuItem>
    </DropdownMenuContent>
</DropdownMenu>

Complex Example

Combining all features: labels, separators, groups, shortcuts, and disabled items.

Checkbox Items

Menu items that toggle a boolean state. Useful for preferences and settings.

Status Bar: Visible

Activity Bar: Visible

Panel: Hidden

Radio Items

A group of menu items where only one can be selected at a time.

Selected position: bottom

Submenus

Nested menus for organizing complex options. Hover or use arrow keys to open submenus.

API Reference

Component parameters and their types.

Prop Type Default Description
ChildContent RenderFragment? null Trigger and content elements for the dropdown.
AsChild bool false On DropdownMenuTrigger: merges trigger behavior onto the child element.
Align PopoverAlign Start On DropdownMenuContent: alignment relative to trigger. Options: Start, Center, End.
Class string? null Additional CSS classes for the component.
Disabled bool false On DropdownMenuItem: prevents interaction when true.
OnClick EventCallback On DropdownMenuItem: callback when item is clicked.
Checked bool false On DropdownMenuCheckboxItem: the checked state. Use @bind-Checked.
Value TValue On DropdownMenuRadioItem: the value this item represents.

Reconnecting...

Attempting to rejoin the server

Connection Lost

Retrying in seconds

Connection Failed

Failed to rejoin the server.
Please retry or reload the page.

Session Paused

The session has been paused by the server

Resume Failed

Failed to resume the session.
Please reload the page.