Importimport { Dropdown } from "antd"; |
Sourcecomponents/dropdown |
Importimport { Dropdown } from "antd"; |
Sourcecomponents/dropdown |
When there are more than a few options to choose from, you can wrap them in a Dropdown
. By hovering or clicking on the trigger, a dropdown menu will appear, which allows you to choose an option and execute the relevant action.
Common props ref:Common props
Property | Description | Type | Default | Version |
---|---|---|---|---|
arrow | Whether the dropdown arrow should be visible | boolean | { pointAtCenter: boolean } | false | |
autoAdjustOverflow | Whether to adjust dropdown placement automatically when dropdown is off screen | boolean | true | 5.2.0 |
autoFocus | Focus element in overlay when opened | boolean | false | |
disabled | Whether the dropdown menu is disabled | boolean | - | |
Whether destroy dropdown when hidden, use destroyOnHidden instead | boolean | false | ||
destroyOnHidden | Whether destroy dropdown when hidden | boolean | false | 5.25.0 |
Customize dropdown content, use popupRender instead | (menus: ReactNode) => ReactNode | - | 4.24.0 | |
popupRender | Customize popup content | (menus: ReactNode) => ReactNode | - | 5.25.0 |
getPopupContainer | To set the container of the dropdown menu. The default is to create a div element in body, but you can reset it to the scrolling area and make a relative reposition. Example on CodePen | (triggerNode: HTMLElement) => HTMLElement | () => document.body | |
menu | The menu props | MenuProps | - | |
The class name of the dropdown root element, please use classNames.root instead | string | - | ||
The style of the dropdown root element, please use styles.root instead | CSSProperties | - | ||
placement | Placement of popup menu: bottom bottomLeft bottomRight top topLeft topRight | string | bottomLeft | |
trigger | The trigger mode which executes the dropdown action. Note that hover can't be used on touchscreens | Array<click |hover |contextMenu > | [hover ] | |
open | Whether the dropdown menu is currently open | boolean | - | |
onOpenChange | Called when the open state is changed. Not trigger when hidden by click item | (open: boolean, info: { source: 'trigger' | 'menu' }) => void | - | info.source : 5.11.0 |
Please ensure that the child node of Dropdown
accepts onMouseEnter
, onMouseLeave
, onFocus
, onClick
events.
Token Name | Description | Type | Default Value |
---|---|---|---|
paddingBlock | Vertical padding of dropdown | undefined | PaddingBlock<string | number> | 5 |
zIndexPopup | z-index of dropdown | number | 1050 |
You can use width: max-content
style to handle this. ref #43025.