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
certara-dropdown
Properties
Property | Attribute | Description | Type | Default |
---|---|---|---|---|
buttonColor | button-color | Supports any color available in <certara-button> | "brand" | "danger" | "inverse" | "neutral" | "secondary" | "success" | "warning" | 'secondary' |
buttonLabel | button-label | string | undefined | |
buttonSize | button-size | Supports any size available in <certara-button> | "lg" | "md" | "sm" | 'md' |
buttonVariant | button-variant | Supports any variant available in <certara-button> | "default" | "icon" | "link" | "outline" | 'default' |
menuOffset | menu-offset | number | 10 | |
nested | nested | Specify that a nested dropdown can act as a submenu item of a containing dropdown | boolean | false |
placement | placement | These 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' |
position | position | This can be set to fixed if the dropdown menu is clipped by a bounding parent element | "absolute" | "fixed" | 'absolute' |
showOpenerCaret | show-opener-caret | If set to false , the dropdown opener will not show a caret icon | boolean | true |
Events
Event | Description | Type |
---|---|---|
certaraDropdownClose | CustomEvent<void> | |
certaraDropdownOpen | CustomEvent<void> |
Slots
Slot | Description |
---|---|
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
NameDescriptionCopy
- Dropdown headerCreates a header
- Dropdown dividerCreates a line/separator
@standardDropdown(icon = "", label = "") { @standardDropdownItem(…)}
PropTypeDefaultDescriptionCopy
- labelstringblankcreates a label for the dropdown toggle button
- iconstringblankname of Font Awesome SVG icon (without the
fa-
prefix). Creates an optional icon next to the label on the dropdown toggle button.
Custom button options
Menu positions/options
<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.
<ul class="dropdown-menu" role="menu" aria-labelledby="{{match button-id}}"> ...</ul>
<ul class="dropdown-menu dropdown-menu-right" role="menu" aria-labelledby="{{match button-id}}"> ...</ul>
<div class="dropup"> <button id="dropdown" type="button" class="btn btn--secondary dropdown-toggle" data-toggle="dropdown" data-display="static" aria-haspopup="true" aria-expanded="false"> <ul class="dropdown-menu" role="menu" aria-labelledby="{{match button-id}}">...</ul></div>
<ul class="dropdown-menu dropdown-menu--animate" role="menu" aria-labelledby="{{match button-id}}"> ...</ul>
Nested dropdowns
<certara-dropdown>
can be nested within itself using the nested
attribute.
Accessibility
Note that dropdowns are keyboard friendly, since pressing ESC will hide active dropdowns.
ARIA (screen reader support)
"aria-labelledby"
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.