Skip to content

Dropdown ​

Brief Introduction ​

The Dropdown component is used to display a set of actions or menu items. mengyue-components has encapsulated it and performed vitest testing. You can use <MYDropdown></MYDropdown> or <MYDropdown /> to implement a dropdown menu component.

Basic Usage ​

Basic Dropdown Menu ​

Default dropdown menu with hover trigger.

Code Demo
展开代码

Click Trigger ​

Use the trigger prop set to click to trigger the dropdown menu on click.

Code Demo
展开代码

Split Button ​

Use the split-button prop to create a split button dropdown menu.

Code Demo
展开代码

Different Sizes ​

Use the size prop to set the dropdown menu size.

Code Demo
展开代码

Custom Colors ​

Use the backGroundColor and textColor props to customize the dropdown menu colors.

Code Demo
展开代码

Hide Dropdown Arrow ​

Use the no-caret prop to hide the dropdown arrow.

Code Demo
展开代码

Use icons in DropdownItem.

Code Demo
展开代码

API Reference ​

PropDescriptionTypeOptionsDefault
typeButton typestringdefault/primarydefault
sizeSizestringsm/md/lgmd
split-buttonWhether it's a split buttonboolean—false
disabledWhether to disableboolean—false
placementMenu popup positionstringbottom/top/left/right, etc.bottom
triggerTrigger methodstringhover/clickhover
hide-on-clickWhether to hide menu after clicking itemboolean—true
show-timeoutShow delay (for hover trigger)number—150
hide-timeoutHide delay (for hover trigger)number—150
max-heightMaximum height of menustring | number—null
back-ground-colorBackground colorstring—''
text-colorText colorstring—''
no-caretWhether to hide dropdown arrowboolean—false
teleportedWhether to use teleportboolean—true
PropDescriptionTypeOptionsDefault
commandCommandstring | number | object—null
disabledWhether to disableboolean—false
dividedWhether to show dividerboolean—false
iconIcon componentstring | object—null

Events ​

Event NameDescriptionParameters
commandTriggered when a menu item is clickedcommand: string | number | object
clickTriggered when the button is clickedevent: MouseEvent
visible-changeTriggered when menu visibility changesvisible: boolean

Type Definitions ​

typescript
interface DropdownProps {
  type?: string;
  size?: string;
  splitButton?: boolean;
  disabled?: boolean;
  placement?: string;
  trigger?: string;
  hideOnClick?: boolean;
  showTimeout?: number;
  hideTimeout?: number;
  maxHeight?: string | number;
  backGroundColor?: string;
  textColor?: string;
  noCaret?: boolean;
  teleported?: boolean;
}

interface DropdownItemProps {
  command?: string | number | object;
  disabled?: boolean;
  divided?: boolean;
  icon?: string | object;
}

Released under the MIT License.