You are viewing a PR preview for PR #1506

Agriculture Design System
Beta
Design System for the Export Service

Dropdown menu

A dropdown menu displays a list of actions when a trigger is pressed.

View in StorybookView in Github
import { ... } from '@ag.ds-next/react/dropdown-menu';

Usage

Dropdown menu components can be imported via the dropdown-menu entrypoint in the @ag.ds-next/react package.

For example:

import { ... } from '@ag.ds-next/react/dropdown-menu';

Props

DropdownMenu Props
PropTypeDescription
childrenReactNode | ((menuState: { isMenuOpen: boolean; }) => ReactNode)
popoverMaxHeight?numberThe max height of the dropdown panel popover.
popoverOffset?numberUsed to control the vertical distance between the reference element and popover element. Value is in pixels.
popoverPlacement?DropdownMenuPopoverPlacementDefault: "bottom-start"The placement of the dropdown panel popover in relation to the dropdown menu button.
DropdownMenuButton Props
PropTypeDescription
aria-describedby?stringIdentifies the element (or elements) that describes the object.
aria-label?stringDescribes the button element to assistive technologies.
block?booleanIf true, the button will stretch to the fill the width of its container.
children?ReactNode
disabled?booleanWhen true, prevents onClick from firing.
iconAfter?ComponentType<IconProps>The icon to display after the buttons children.
iconBefore?ComponentType<IconProps>The icon to display before the buttons children.
loading?booleanWhen true, the button will display a loading indicator.
loadingLabel?stringText to read out to assistive technologies when button is loading.
onBlur?FocusEventHandler<HTMLButtonElement>Function to be fired following a blur event of the button.
onFocus?FocusEventHandler<HTMLButtonElement>Function to be fired following a focus event of the button.
onKeyDown?KeyboardEventHandler<HTMLButtonElement>Function to be fired following a keydown event of the button.
role?AriaRoleWAI-ARIA role.
size?"sm" | "md"The size of the button.
tabIndex?numberThe `tabIndex` attribute of the button.
type?"button" | "reset" | "submit"The `type` attribute of the button.
variant?"text" | "primary" | "secondary" | "tertiary"Default: "text"The variant of the button.
DropdownMenuPanel Props
PropTypeDescription
children?ReactNode
palette?ResponsiveProp<"dark" | "light">
DropdownMenuItem Props
PropTypeDescription
as?ElementType<any>
children?ReactNode
endElement?ReactNodeUsed to add decorative elements to the end of the item such as Indicator dot or Notification badge.
icon?ComponentType<IconProps>Used to add an icon to the start of the item.
id?stringDefines an identifier (ID) which must be unique.
onClick?(() => void)Function to be fired following a click event of the item.
ref?Ref<Comp extends "symbol" | "text" | "switch" | "image" | "pattern" | "svg" | "animate" | "animateMotion" | "animateTransform" | "circle" | "clipPath" | "defs" | ... 47 more ... | keyof HTMLElementTagNameMap ? ElementTagNameMap[Comp] : Comp extends new (...args: any) => any ? InstanceType<...> : undefined>
DropdownMenuItemLink Props
PropTypeDescription
aria-label?stringDescribes the anchor element to assistive technologies.
children?ReactNode
download?anyCauses the browser to treat the linked URL as a download.
endElement?ReactNodeUsed to add decorative elements to the end of the item such as Indicator dot or Notification badge.
href?stringThe URL that the hyperlink points to.
icon?ComponentType<IconProps>Used to add an icon to the start of the item.
id?stringThe ID of the hyperlink.
referrerPolicy?HTMLAttributeReferrerPolicyHow much of the referrer to send when following the link.
rel?stringThe relationship of the linked URL as space-separated link types.
role?AriaRoleWAI-ARIA role.
target?HTMLAttributeAnchorTargetWhere to display the linked URL, as the name for a browsing context (a tab, window, or <iframe>).
DropdownMenuItemRadio Props
PropTypeDescription
checkedbooleanExposes the radio buttons state to assistive technology.
children?ReactNode
endElement?ReactNodeUsed to add decorative elements to the end of the item such as Indicator dot or Notification badge.
id?stringDefines an identifier (ID) which must be unique.
onClick?(() => void)Function to be fired following a click event of the item.
secondaryText?stringSupporting text for the item.

DropdownMenuDivider Props

DropdownMenuDivider does not have any props.

DropdownMenuGroup Props
PropTypeDescription
labelstringThe label of the group.
children?ReactNode
DropdownMenuGroupLink Props
PropTypeDescription
aria-label?stringDescribes the anchor element to assistive technologies.
children?ReactNode
download?anyCauses the browser to treat the linked URL as a download.
href?stringThe URL that the hyperlink points to.
id?stringThe ID of the hyperlink.
referrerPolicy?HTMLAttributeReferrerPolicyHow much of the referrer to send when following the link.
rel?stringThe relationship of the linked URL as space-separated link types.
role?AriaRoleWAI-ARIA role.
target?HTMLAttributeAnchorTargetWhere to display the linked URL, as the name for a browsing context (a tab, window, or <iframe>).

Source

You can view the full source code for this package on Github.