Skip to main content

MenuListbox

A MenuListbox is a standalone, always-visible list container that supports single-select and multi-select modes. It supports grouping with category headers, dividers, icons, helper text, and descriptions.

Import

// with @dhl-official/react-library:
import { DhlMenuListbox } from "@dhl-official/react-library"
// with @dhl-official/ui-libraries/react-library:
import { DhlMenuListbox } from "@dhl-official/ui-libraries/react-library"

Code

<DhlMenuListbox
data={[
{ label: "Urgent", value: "urgent" },
{ label: "High", value: "high" },
{ label: "Medium", value: "medium" },
{ label: "Low", value: "low" },
]}
dataAriaLabel="Priority"
onDhlChange={(e) => console.log(e.detail.value)}
/>

Interactive Demo

Readme

Properties

PropertyAttributeDescriptionTypeDefault
datadataAn optional array of items to display in the listbox.DhlMenuListboxItemType[][]
dataAriaLabeldata-aria-labelAn optional aria-label for the listbox, used when there is no visible label element.stringundefined
dataAriaLabelledbydata-aria-labelledbyAn optional aria-labelledby value referencing the id of an external label element.stringundefined
dataIdidAn optional unique HTML id for the component. Used to link external labels via aria-labelledby.string`dhl-menu-listbox-${getRandomString()}`
dataTestiddata-testidAn optional data-testid attribute for testing.stringundefined
multiSelectmulti-selectAn optional flag to enable multi-select mode. When false (default) only one item can be selected at a time.booleanfalse
notFoundLabelnot-found-labelAn optional label shown in the empty / no-results state.string"Item not found"
valuevalueAn optional selected value for single-select mode. Setting this prop initialises the selection.stringundefined
valuesvaluesAn optional array of selected values for multi-select mode.string[][]

Events

EventDescriptionType
dhlChangeEmitted when the selection changes. The detail always includes both value (first selected string) and values (full selection array).CustomEvent<{ value: string; values: string[]; }>

Dependencies

Depends on

  • dhl-selection-option

Graph


Built by DHL User Interface Library Team!