Dropdown menu
A dropdown menu displays a list of actions or options to a user.Neutral selected states
When the platform-dst-tokens-finesse feature flag is enabled, this component uses the new neutral treatment for selected states.
Motion in Early Access
Motion updates for this component are in Early Access and available behind the platform-dst-motion-uplift-popup feature flag.
Installation
| Install | yarn add @atlaskit/dropdown-menu |
|---|---|
| Source | Bitbucket.org, (opens new window) |
| npm | @atlaskit/dropdown-menu, (opens new window) |
| Bundle | unpkg.com, (opens new window) |
Props
| Description | Controls the appearance of the menu. The default menu will scroll after its height exceeds the pre-defined amount. The tall menu won't scroll until the height exceeds the height of the viewport. |
|---|---|
| Type | "default" | "tall" |
| Description | Controls if the first menu item receives focus when menu is opened. Note that the menu has a focus lock which traps the focus within the menu. The first item gets focus automatically if the menu is triggered using the keyboard. |
|---|---|
| Type | boolean |
| Description | Content that will be rendered inside the layer element. Should typically be
|
|---|---|
| Type | string | number | boolean | React.ReactElement<any, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | React.ReactPortal |
| Description | Controls the initial open state of the dropdown. If provided, the component is considered to be controlled
which means that the user is responsible for managing the open and close state of the menu.
Using |
|---|---|
| Type | boolean |
| Description | An optional name used to identify events for React UFO (Unified Frontend Observability) press interactions. For more information, see React UFO integration into Design System components. |
|---|---|
| Type | string |
| Description | If true, a spinner is rendered instead of the items. |
|---|---|
| Type | boolean |
| Description | Controls the open state of the dropdown. |
|---|---|
| Type | boolean |
| Description | Provide an accessible label via |
|---|---|
| Type | string |
| Description | Called when the menu should be open/closed. Receives an object with If the dropdown was closed programatically, the |
|---|---|
| Type | (args: OnOpenChangeArgs) => void |
| Description | Position of the menu. |
|---|---|
| Type | "auto-start" | "auto" | "auto-end" | "top-start" | "top" | "top-end" | "right-start" | "right" | "right-end" | "bottom-end" | "bottom" | "bottom-start" | "left-end" | "left" | "left-start" |
| Description | If ref is passed, focus returns to that specific ref element after dropdown dismissed. |
|---|---|
| Type | React.RefObject<HTMLElement> |
| Description | This fits the dropdown menu width to its parent's width.
When set to This fits the dropdown menu width to its parent's width.
When set to |
|---|---|
| Type | boolean |
| Description | Allows the dropdown menu to be placed on the opposite side of its trigger if it does not fit in the viewport. @private
No-op when |
|---|---|
| Type | boolean |
| Description | Allows consumers to ignore specific close events, for example when an external overlay should be treated as part of the dropdown interaction. |
|---|---|
| Type | (event: Event | React.MouseEvent<Element, MouseEvent> | React.KeyboardEvent<Element>) => boolean |
| Description | When set to true, will call stopPropagation on the ESCAPE key event. This prevents the ESCAPE event from bubbling up to parent elements. @private
No-op when |
|---|---|
| Type | boolean |
| Description | Controls whether the popup is rendered inline within its parent component or in a portal at the document root.
@private
No-op when @private
@deprecated No-op when |
|---|---|
| Type | boolean |
| Description | Controls the spacing density of the menu. |
|---|---|
| Type | "compact" | "cozy" |
| Description | Text to be used as status for assistive technologies. Defaults to "Loading". |
|---|---|
| Type | string |
| Description | This controls the positioning strategy to use. Can vary between @private
No-op when @private
@deprecated No-op when |
|---|---|
| Type | "absolute" | "fixed" |
| Description | A As dropdown-menu is composed of different components, we passed down the testId to the sub component you want to test:
|
|---|---|
| Type | string |
| Description | Content that triggers the dropdown menu to open and close. Use with
|
|---|---|
| Type | string | ((triggerButtonProps: CustomTriggerProps<T>) => React.ReactElement<any, string | React.JSXElementConstructor<any>>) |
| Description | Z-index that the popup should be displayed in.
This is passed to the portal component.
Defaults to @private
No-op when |
|---|---|
| Type | number |