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 In this example, the dropdown is activated by clicking an RzAvatar. The menu options include Dashboard, Settings, and Sign Out. This example showcases a dropdown activated by a Button. The menu is organized into multiple groups using This component accepts no specific parameters other than standard HTML attributes via This page uses 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.<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>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.<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>Property Description Type Default 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.BottomOffsetint – Offset in pixels from the anchor point.int4IsModalbool – Determines if the dropdown behaves modally (traps focus).boolfalseProperty Description Type Default ChildContentRenderFragment – The content that serves as the interactive trigger for the dropdown (e.g., an RzAvatar, RzButton).RenderFragmentRequired Property Description Type Default ChildContentRenderFragment – The menu content rendered inside the dropdown panel. Typically includes DropdownMenuItem, DropdownMenuGroup, etc.RenderFragmentRequired Property Description Type Default ChildContentRenderFragment – The text or content of the label.RenderFragmentRequired Property Description Type Default ChildContentRenderFragment – The content of the group, typically DropdownMenuItems.RenderFragmentRequired Property Description Type Default ChildContentRenderFragment – The primary text content of the menu item.RenderFragmentRequired IconSvgIcon? – An optional icon (from Blazicons) to display before the item content.SvgIcon?nullShortcutContentRenderFragment? – Optional content to display as a shortcut hint (e.g., using DropdownMenuShortcut).RenderFragment?nullDisabledbool – If true, the menu item will be disabled and non-interactive.boolfalseAdditionalAttributes.Property Description Type Default ChildContentRenderFragment – The text or content of the shortcut hint (e.g., "⌘S").RenderFragmentRequired Property Description Type Default ChildContentRenderFragment – Contains the DropdownMenuSubTrigger and DropdownMenuSubContent components.RenderFragmentRequired AnchorAnchorPoint – Preferred alignment of the sub-menu content relative to its trigger.AnchorPointAnchorPoint.RightStartOffsetint – Offset in pixels for the sub-menu content.int-4Property Description Type Default ChildContentRenderFragment – The text or content of the sub-menu trigger.RenderFragmentRequired IconSvgIcon? – An optional icon to display before the trigger content.SvgIcon?nullProperty Description Type Default ChildContentRenderFragment – The content rendered inside the sub-menu panel, typically DropdownMenuItems.RenderFragmentRequired rzDropdownMenu Alpine x-data component.Method Parameters Description toggle—Toggles the menu open/closed. updatePosition—Recomputes floating position for menu content.