Skip to content

Dropdown Menu

Dropdown menus are typically used when you have 5-15 items to choose from. They’re used for navigation or command menus, where an action is initiated based on the selection.

Menu items can include checkboxes.

Code

Dropdown Item Dropdown Item Dropdown Item Dropdown Item
Dropdown Item Dropdown Item Dropdown Item Dropdown Item
packages/certara-ui/src/components/dropdown/dropdown.tsx
<certara-dropdown button-label="Drop Down">
<certara-dropdown-item>Dropdown Item</certara-dropdown-item>
<certara-dropdown-item>Dropdown Item</certara-dropdown-item>
<certara-dropdown-item>Dropdown Item</certara-dropdown-item>
<certara-dropdown-item>Dropdown Item</certara-dropdown-item>
</certara-dropdown>

certara-dropdown

Properties

PropertyAttributeDescriptionTypeDefault
buttonColorbutton-colorSupports any color available in <certara-button>"brand" | "danger" | "inverse" | "neutral" | "secondary" | "success" | "warning"'secondary'
buttonLabelbutton-labelstringundefined
buttonSizebutton-sizeSupports any size available in <certara-button>"lg" | "md" | "sm"'md'
buttonVariantbutton-variantSupports any variant available in <certara-button>"default" | "icon" | "link" | "outline"'default'
menuOffsetmenu-offsetnumber10
nestednestedSpecify that a nested dropdown can act as a submenu item of a containing dropdownbooleanfalse
placementplacementThese options will suggest a starting point for the menu position, but <certara-dropdown> will automatically position itself within the viewport to avoid appearing offscreen"bottom-end" | "bottom-start" | "left-start" | "right-end" | "right-start" | "top-end" | "top-start"'bottom-start'
positionpositionThis can be set to fixed if the dropdown menu is clipped by a bounding parent element"absolute" | "fixed"'absolute'
showOpenerCaretshow-opener-caretIf set to false, the dropdown opener will not show a caret iconbooleantrue

Events

EventDescriptionType
certaraDropdownCloseCustomEvent<void>
certaraDropdownOpenCustomEvent<void>

Slots

SlotDescription
Main slot is reserved for <certara-dropdown-*> elements, but it does accept all children
"button-label"Can be used for custom label content, including icons

Dependencies

Depends on

Graph

graph TD;
certara-dropdown --> certara-icon
certara-dropdown --> certara-button
certara-button --> certara-icon
style certara-dropdown fill:#f9f,stroke:#333,stroke-width:4px

Custom button options

Dropdown Item Dropdown Item Dropdown Item Dropdown Item
<certara-dropdown button-label="Color" button-color="brand">
<certara-dropdown-item>Dropdown Item</certara-dropdown-item>
<certara-dropdown-item>Dropdown Item</certara-dropdown-item>
<certara-dropdown-item>Dropdown Item</certara-dropdown-item>
<certara-dropdown-item>Dropdown Item</certara-dropdown-item>
</certara-dropdown>

<certara-dropdown> will position the menu automatically to stay within the viewport, but can be set to show in a specific orientation with the placement attribute.

Dropdown Item Dropdown Item Dropdown Item Dropdown Item
<certara-dropdown placement="bottom-start" button-label="Actions">
<certara-dropdown-item>Dropdown Item</certara-dropdown-item>
<certara-dropdown-item>Dropdown Item</certara-dropdown-item>
<certara-dropdown-item>Dropdown Item</certara-dropdown-item>
<certara-dropdown-item>Dropdown Item</certara-dropdown-item>
</certara-dropdown>

Nested dropdowns

<certara-dropdown> can be nested within itself using the nested attribute.

Dropdown Item Dropdown Item Dropdown Item Dropdown Item Nested Item Nested Item
<certara-dropdown button-label="With nested options">
<certara-dropdown-item>Dropdown Item</certara-dropdown-item>
<certara-dropdown-item>Dropdown Item</certara-dropdown-item>
<certara-dropdown-item>Dropdown Item</certara-dropdown-item>
<certara-dropdown-item>Dropdown Item</certara-dropdown-item>
<certara-dropdown button-label="Nested options" nested>
<certara-dropdown-item>Nested Item</certara-dropdown-item>
<certara-dropdown-item>Nested Item</certara-dropdown-item>
</certara-dropdown>
</certara-dropdown>

Accessibility

Note that dropdowns are keyboard friendly, since pressing ESC will hide active dropdowns.

ARIA (screen reader support)

"aria-labelledby" allows a developer to associate the dropdown menu (aria-labelledby=“dropdownTrigger”) to the element that triggers it (id=“dropdownTrigger”). This allows the dropdown trigger to be not only visually associated with its corresponding dropdown menu; it is programmatically associated with it too. This means that, for example, a screen reader will read out the dropdown trigger when the user is focused on the button, making it easier for an assistive technology user to understand what menu the button/trigger is controlling.

Design resources

View component in Figma