Dropdowns are floating lists that can be revealed by an event such as a button click or select tag.
Overview
Dropdowns can be single or multi-selectable lists. Every Dropdown Item must have a parent Dropdown Group.
Sample
Usage
- Filter and sort interactions
- Selection lists
Accessibility
Keyboard navigation
| Key | Function |
|---|---|
Arrow down | If the component is not open, opens the component. When open, moves focus to next non-disabled calcite-dropdown-item. If the current focus is the last calcite-dropdown-item, focus will cycle to the first calcite-dropdown-item. |
Arrow up | If the component is not open, opens the component. When open, moves focus to previous non-disabled calcite-dropdown-item. If the current focus is the first calcite-dropdown-item, the focus will cycle to the last calcite-dropdown-item. |
Esc | If the component is open, closes the component. |
Home | Moves focus to the component's first calcite-dropdown-item. |
End | Moves focus to the component's last calcite-dropdown-item. |
Enter | Selects the active calcite-dropdown-item and when close is false (default), closes the component. |
Space | Selects the active calcite-dropdown-item and when close is false (default), closes the component. |
Tab | Moves focus in and out of the component. |
Tab and Shift | Moves focus in and out of the component. |
API reference
Properties
| Property | Attribute | Description | Type | Default |
|---|---|---|---|---|
| closeOnSelectDisabled | close-on-select-disabled | When If the | boolean | false |
| disabled | disabled | When | boolean | false |
| flipPlacements | Specifies the component's fallback | FlipPlacement[] | ||
| maxItems | max-items | Specifies the maximum number of | number | 0 |
| offsetDistance | offset-distance | Specifies the distance to position the component away from the | number | 0 |
| offsetSkidding | offset-skidding | Specifies the distance to position the component along the | number | 0 |
| open | open | When | boolean | false |
| overlayPositioning | overlay-positioning | Specifies the type of positioning to use for overlaid content, where:
| OverlayPositioning | "absolute" |
| placement | placement | Determines the component's placement relative to the container element. | LogicalPlacement | "bottom-start" |
| referenceElement | reference-element | The Setting the value to an However, a string The component should not be placed within its own | ReferenceElement | string | null | |
| scale | scale | Specifies the size of the component. | Scale | "m" |
| selectedItems | The component's selected items. | DropdownItem[] | ||
| topLayerDisabled | top-layer-disabled | When Only set this if you need complex z-index control or if top layer placement causes conflicts with third-party components. | boolean | false |
| type | type | Specifies the type of action on the container element to open the component. | "hover" | "click" | "click" |
| width | width | Specifies the component's width. | Extract<Width, Scale> | |
| widthScale | width-scale | width property instead.Specifies the component's width. | Scale |
Slots
| Name | Description |
|---|---|
| default (unnamed) | A slot for adding |
| trigger | referenceElement property instead. A slot for the element that triggers the component. |
Styles
| Name | Description |
|---|---|
| --calcite-dropdown-width | Specifies the width of the component's wrapper. |
| --calcite-dropdown-background-color | Specifies the component's background color. |
Events
| Name | Description | Behavior |
|---|---|---|
| calciteDropdownBeforeClose | Fires when the component is requested to be closed and before the closing transition begins. | |
| calciteDropdownBeforeOpen | Fires when the component is added to the DOM but not rendered, and before the opening transition begins. | |
| calciteDropdownClose | Fires when the component is closed and animation is complete. | |
| calciteDropdownOpen | Fires when the component is opened and animation is complete. | |
| calciteDropdownSelect | Fires when a |
Methods
| Name | Description | Signature |
|---|---|---|
| componentOnReady | Creates a promise that resolves once the component is fully loaded. | componentOnReady(): Promise<this> |
| reposition | Updates the component's position. | reposition(delayed?: boolean): Promise<void> |
| setFocus | Sets focus on the component's first focusable element. | setFocus(options?: FocusOptions): Promise<void> |