Dropdown

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

Usage

Default

<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

Data table
TypeDescription
align"left" | "right"Menu alignment relative to the trigger ('left' | 'right').
aria-describedbystringAccessible description id(s) for the trigger button.
aria-labelstringAccessible label for the trigger button. Prefer this when the trigger is icon-only.
aria-labelledbystringAccessible labelledby target for the trigger button.
classNamestringCustom class name for the dropdown wrapper.
closeOnSelectbooleanWhether the menu should close after selecting an item. Default is usually true for action menus.
data-testidstringOptional test ID for testing frameworks.
focusFirstItemOnOpenbooleanWhether keyboard focus should move to the first item when the menu opens. Default behavior in your base already does this logically.
itemsDropdownItem[]Array of items to render in the dropdown menu.
menuAriaDescribedbystringAccessible description id(s) for the menu.
menuAriaLabelstringAccessible label for the menu itself. Falls back to `aria-label` in many implementations.
menuAriaLabelledbystringAccessible labelledby target for the menu. Prefer this over `menuAriaLabel` when visible text labels the menu.
menuClassNamestringCustom class name for the dropdown menu.
menuIdstringOptional id for the menu element. Useful when composing with external controls/tests.
menuRoundingRoundingTypeRounding of the dropdown menu ('none' | 'small' | 'medium' | 'large' | 'full').
menuShadowShadowTypeShadow style for the dropdown menu ('none' | 'light' | 'medium' | 'strong' | 'intense').
stateStateTypeState of the dropdown ('success' | 'error' | 'warning' | 'disabled' | '').
themeThemeTypeTheme for styling ('primary' | 'secondary' | 'tertiary' | 'quaternary' | 'clear').
titlestringOptional title/tooltip text for the trigger.
toggleOutlinebooleanWhether to use the outline style on the toggle button.
toggleRoundingRoundingTypeRounding of the toggle button ('none' | 'small' | 'medium' | 'large' | 'full').
toggleShadowShadowTypeShadow style for the toggle button ('none' | 'light' | 'medium' | 'strong' | 'intense').
triggerIconComponentType<{ className?: string; "aria-hidden"?: boolean; focusable?: boolean; }>Icon component used for the trigger button.
triggerIdstringOptional id for the trigger element.