Dropdown

The Dropdown component provides a menu for users to select from options, with customizable appearance, alignment, and items.

Usage & Examples

Default

default.tsx
<Dropdown
    items={[
      { label: "Profile", icon: <FaUser />, onClick: () => alert("View Profile") },
      { label: "Settings", icon: <FaCog />, onClick: () => alert("Settings clicked") },
      { label: "Logout", icon: <FaSignOutAlt />, onClick: () => alert("Logged out"), "data-testid": "logout-button" },
    ]}
  />

Props API

25 props
Columns
Dropdown props API
Default
Description
align"start" | "end"Noprops"end"Menu alignment relative to the trigger ('start' | 'end').
aria-describedbystringNoariaAccessible description id(s) for the trigger button.
aria-labelstringNoaria"Dropdown menu"Whether to use the outline style on the toggle button. Accessible label for the trigger button. Prefer this when the trigger is icon-only.
aria-labelledbystringNoariaAccessible labelledby target for the trigger button.
classNamestringNostylingCustom class name for the dropdown wrapper.
closeOnSelectbooleanNopropstrueWhether the menu should close after selecting an item. Default is usually true for action menus.
data-testidstringNotestingBackward-compatible alias for test ID attributes.
focusFirstItemOnOpenbooleanNopropstrueWhether keyboard focus should move to the first item when the menu opens. Default behavior in your base already does this logically.
itemsDropdownItem[]YespropsArray of items to render in the dropdown menu.
menuAriaDescribedBystringNopropsAccessible description id(s) for the menu.
menuAriaLabelstringNopropsAccessible label for the menu itself. Falls back to `aria-label` in many implementations.
menuAriaLabelledBystringNopropsAccessible labelledby target for the menu. Prefer this over `menuAriaLabel` when visible text labels the menu.