RizzyUI

Dropdown Menu

Dropdown menus provide a user-friendly and space-efficient way to display a list of options or actions. When the trigger element is activated (via click or keyboard events), the dropdown menu appears with a smooth transition. The component supports any renderable trigger (such as a Button, RzAvatar, etc.), multiple menu groups, labels, separators, and nested sub-menus. Dynamic alignment is handled via the Anchor property on RzDropdownMenu and DropdownMenuSub. Full keyboard accessibility is supported. All interactivity is handled via Alpine.js (using the rzDropdownMenu and rzDropdownSubmenu data objects), ensuring a CSP-compliant, accessible experience.

Dropdown with RzAvatar Trigger

In this example, the dropdown is activated by clicking an RzAvatar. The menu options include Dashboard, Settings, and Sign Out.

Source
<RzDropdownMenu Anchor="AnchorPoint.Bottom">
    <DropdownMenuTrigger>
        <RzAvatar Size="Size.Medium">
            <AvatarImage ImageSource="/images/profile/51.jpg" AlternateText="User 51 Medium" />
        </RzAvatar>
    </DropdownMenuTrigger>
    <DropdownMenuContent class="w-56">
        <DropdownMenuLabel>My Account</DropdownMenuLabel>
        <DropdownMenuSeparator />
        <DropdownMenuGroup>
            <DropdownMenuItem Icon="MdiIcon.Home">Dashboard</DropdownMenuItem>
            <DropdownMenuItem Icon="MdiIcon.Cog">Settings</DropdownMenuItem>
        </DropdownMenuGroup>
        <DropdownMenuSeparator />
        <DropdownMenuItem Icon="MdiIcon.Logout">Sign Out</DropdownMenuItem>
    </DropdownMenuContent>
</RzDropdownMenu>

Button Dropdown with Groups & Sub-menu

This example showcases a dropdown activated by a Button. The menu is organized into multiple groups using DropdownMenuGroup and separated by DropdownMenuSeparator. It also includes a sub-menu for "Invite users" using DropdownMenuSub, DropdownMenuSubTrigger, and DropdownMenuSubContent. Shortcuts are displayed using the DropdownMenuShortcut component.

Source
<RzDropdownMenu Anchor="AnchorPoint.Bottom">
    <DropdownMenuTrigger AsChild>
        <RzButton Variant="ThemeVariant.Primary">Open Menu</RzButton>
    </DropdownMenuTrigger>
    <DropdownMenuContent class="w-56">
        <DropdownMenuLabel>My Account</DropdownMenuLabel>
        <DropdownMenuSeparator />
        <DropdownMenuGroup>
            <DropdownMenuItem Icon="MdiIcon.AccountCircleOutline">
                Profile
                <DropdownMenuShortcut>⇧⌘P</DropdownMenuShortcut>
            </DropdownMenuItem>
            <DropdownMenuItem Icon="MdiIcon.CreditCardOutline">
                Billing
                <DropdownMenuShortcut>⌘B</DropdownMenuShortcut>
            </DropdownMenuItem>
            <DropdownMenuItem Icon="MdiIcon.CogOutline">
                Settings
                <DropdownMenuShortcut>⌘S</DropdownMenuShortcut>
            </DropdownMenuItem>
        </DropdownMenuGroup>
        <DropdownMenuSeparator />
        <DropdownMenuGroup>
            <DropdownMenuItem Icon="MdiIcon.AccountGroupOutline">Team</DropdownMenuItem>
            <DropdownMenuSub>
                <DropdownMenuSubTrigger Icon="MdiIcon.AccountPlusOutline">
                    Invite users
                </DropdownMenuSubTrigger>
                <DropdownMenuSubContent class="w-48">
                    <DropdownMenuItem Icon="MdiIcon.EmailOutline">Email</DropdownMenuItem>
                    <DropdownMenuItem Icon="MdiIcon.MessageOutline">Message</DropdownMenuItem>
                    <DropdownMenuSeparator />
                    <DropdownMenuItem>More...</DropdownMenuItem>
                </DropdownMenuSubContent>
            </DropdownMenuSub>
            <DropdownMenuItem Icon="MdiIcon.PlusBoxOutline">
                New Team
                <DropdownMenuShortcut>⌘+T</DropdownMenuShortcut>
            </DropdownMenuItem>
        </DropdownMenuGroup>
        <DropdownMenuSeparator />
        <DropdownMenuItem Icon="MdiIcon.Github">GitHub</DropdownMenuItem>
        <DropdownMenuItem Icon="MdiIcon.Lifebuoy">Support</DropdownMenuItem>
        <DropdownMenuItem Disabled="true" Icon="MdiIcon.CloudOutline">API</DropdownMenuItem>
        <DropdownMenuSeparator />
        <DropdownMenuItem Icon="MdiIcon.Logout">
            Log out
            <DropdownMenuShortcut>⇧⌘Q</DropdownMenuShortcut>
        </DropdownMenuItem>
    </DropdownMenuContent>
</RzDropdownMenu>

RzDropdownMenu Component Parameters

PropertyDescriptionTypeDefault
ChildContentRenderFragment – Contains the DropdownMenuTrigger and DropdownMenuContent components.RenderFragmentRequired
AnchorAnchorPoint – Preferred alignment of the dropdown relative to its trigger. Options include TopStart, Top, TopEnd, LeftStart, Left, LeftEnd, RightStart, Right, RightEnd, BottomStart, Bottom, BottomEnd.AnchorPointAnchorPoint.Bottom
Offsetint – Offset in pixels from the anchor point.int4
IsModalbool – Determines if the dropdown behaves modally (traps focus).boolfalse

DropdownMenuTrigger Component Parameters

PropertyDescriptionTypeDefault
ChildContentRenderFragment – The content that serves as the interactive trigger for the dropdown (e.g., an RzAvatar, RzButton).RenderFragmentRequired

DropdownMenuContent Component Parameters

PropertyDescriptionTypeDefault
ChildContentRenderFragment – The menu content rendered inside the dropdown panel. Typically includes DropdownMenuItem, DropdownMenuGroup, etc.RenderFragmentRequired

DropdownMenuLabel Component Parameters

PropertyDescriptionTypeDefault
ChildContentRenderFragment – The text or content of the label.RenderFragmentRequired

DropdownMenuGroup Component Parameters

PropertyDescriptionTypeDefault
ChildContentRenderFragment – The content of the group, typically DropdownMenuItems.RenderFragmentRequired

DropdownMenuItem Component Parameters

PropertyDescriptionTypeDefault
ChildContentRenderFragment – The primary text content of the menu item.RenderFragmentRequired
IconSvgIcon? – An optional icon (from Blazicons) to display before the item content.SvgIcon?null
ShortcutContentRenderFragment? – Optional content to display as a shortcut hint (e.g., using DropdownMenuShortcut).RenderFragment?null
Disabledbool – If true, the menu item will be disabled and non-interactive.boolfalse

DropdownMenuSeparator Component Parameters

This component accepts no specific parameters other than standard HTML attributes via AdditionalAttributes.

DropdownMenuShortcut Component Parameters

PropertyDescriptionTypeDefault
ChildContentRenderFragment – The text or content of the shortcut hint (e.g., "⌘S").RenderFragmentRequired

DropdownMenuSub Component Parameters

PropertyDescriptionTypeDefault
ChildContentRenderFragment – Contains the DropdownMenuSubTrigger and DropdownMenuSubContent components.RenderFragmentRequired
AnchorAnchorPoint – Preferred alignment of the sub-menu content relative to its trigger.AnchorPointAnchorPoint.RightStart
Offsetint – Offset in pixels for the sub-menu content.int-4

DropdownMenuSubTrigger Component Parameters

PropertyDescriptionTypeDefault
ChildContentRenderFragment – The text or content of the sub-menu trigger.RenderFragmentRequired
IconSvgIcon? – An optional icon to display before the trigger content.SvgIcon?null

DropdownMenuSubContent Component Parameters

PropertyDescriptionTypeDefault
ChildContentRenderFragment – The content rendered inside the sub-menu panel, typically DropdownMenuItems.RenderFragmentRequired

Alpine API

This page uses the rzDropdownMenu Alpine x-data component.

MethodParametersDescription
toggleToggles the menu open/closed.
updatePositionRecomputes floating position for menu content.