Skip to content

Dropdown

Dropdown

A select-only combobox (APG): a button that opens a listbox of Options. Enter, Space, ArrowDown/ArrowUp, Home/End and typing a character open it and move the highlight (aria-activedescendant); Enter/Space select, Tab selects the highlighted option and moves on, Escape closes. The button's chevron (see expandIcon) turns while the list is open, and renderValue replaces its content while a value is selected. clearable adds a clear button, a tab stop after the combobox button; both sit in a wrapper <div> inside the root.

multiselect turns the value into an array (Fluent's selectedOptions): options draw a checkbox; Enter and Space toggle the highlighted option, a click toggles the clicked option, and the list stays open (Tab, Escape and Alt+ArrowUp close without committing); the button shows the selected labels in selection order (labels.selection, replacing the placeholder while any are selected, values without an option left out) and every toggle the user makes is announced (labels.added/labels.removed, never for a controlled change, a clear or a form reset). clearable then clears every value. A non-literal multiselect={flag} is a type error: render two elements, one for each mode.

**Data mode**: items passes the options as data instead of children. The open list renders an option per item (renderOption draws it, an Option with the item's label by default) and the closed list none; the keys, typeahead and the button's text follow the data, and each option carries aria-posinset and aria-setsize. A long list takes a virtualWindow (from useVirtualWindow({ itemSize })): the open list then renders only the options in view, plus an overscan, with spacers for the others, every option itemSize tall; the active option stays rendered, and opening scrolls it to the middle of the list.

The <button> receives ref, id, aria-label, aria-labelledby, aria-describedby, aria-invalid, aria-required, aria-errormessage, aria-details, tabIndex, autoFocus and onFocus/onBlur/onKeyDown/onKeyUp. className, style, other aria-* attributes and the remaining props stay on the root <div> (slotProps.root.ref reaches it). Inside a Field the button is labelled and described by it — otherwise give it an aria-label. It shows the error look whenever it ends up aria-invalid (its own aria-invalid or a Field error). With name/required the value takes part in form submission (one hidden input per value with multiselect), validation and reset (a multiselect reset is compared by content, so restoring the same values reports nothing). The open listbox renders in a portal; while closed it stays in the DOM, hidden.

**Size and appearance**: size resolves from its own prop, then the surrounding Field's size, then WaveProvider inputDefaults.size, else 'medium'; appearance from its own prop, then WaveProvider inputDefaults.appearance, else 'outline'; both render as data-size and data-appearance on the root <div>. The listbox keeps its size.

Sub-components: Dropdown.Option, Dropdown.OptionGroup. React Server Components import the flat names DropdownOption / DropdownOptionGroup (dotted access needs a client file).

Examples

Default

export const Default: Story = {
  args: {
    placeholder: 'Select an option',
  },
  render: (args) => (
    <Dropdown {...args}>
      <Dropdown.Option value="cat">Cat</Dropdown.Option>
      <Dropdown.Option value="dog">Dog</Dropdown.Option>
      <Dropdown.Option value="fish">Fish</Dropdown.Option>
      <Dropdown.Option value="hamster">Hamster</Dropdown.Option>
    </Dropdown>
  ),
};

With Default Value

export const WithDefaultValue: Story = {
  args: {
    defaultValue: 'dog',
  },
  render: (args) => (
    <Dropdown {...args}>
      <Dropdown.Option value="cat">Cat</Dropdown.Option>
      <Dropdown.Option value="dog">Dog</Dropdown.Option>
      <Dropdown.Option value="fish">Fish</Dropdown.Option>
    </Dropdown>
  ),
};

Clearable

export const Clearable: Story = {
  args: {
    defaultValue: 'dog',
    clearable: true,
  },
  render: (args) => (
    <Dropdown {...args}>
      <Dropdown.Option value="cat">Cat</Dropdown.Option>
      <Dropdown.Option value="dog">Dog</Dropdown.Option>
      <Dropdown.Option value="fish">Fish</Dropdown.Option>
    </Dropdown>
  ),
};

Grouped

export const Grouped: Story = {
  args: {
    'aria-label': 'Animal',
    placeholder: 'Select an animal',
  },
  render: (args) => (
    <Dropdown {...args}>
      <Dropdown.OptionGroup label="Mammals">
        <Dropdown.Option value="cat">Cat</Dropdown.Option>
        <Dropdown.Option value="dog">Dog</Dropdown.Option>
      </Dropdown.OptionGroup>
      <Dropdown.OptionGroup label="Fish">
        <Dropdown.Option value="goldfish">Goldfish</Dropdown.Option>
        <Dropdown.Option value="shark" disabled>
          Shark (not available)
        </Dropdown.Option>
      </Dropdown.OptionGroup>
    </Dropdown>
  ),
};

Disabled

export const Disabled: Story = {
  args: {
    disabled: true,
    placeholder: 'Disabled',
  },
  render: (args) => (
    <Dropdown {...args}>
      <Dropdown.Option value="a">Alpha</Dropdown.Option>
    </Dropdown>
  ),
};

Multiselect

export const Multiselect: StoryObj<DropdownProps<true>> = {
  args: {
    'aria-label': undefined,
    multiselect: true,
    clearable: true,
  },
  // The spread alone leaves `multiselect` optional (StoryObj widens `args`), which satisfies
  // neither call signature (D9): the literal attribute after it forces the multi-select one.
  render: (args) => (
    <Field label="Fruits">
      <Dropdown {...args} multiselect>
        <Dropdown.Option value="apple">Apple</Dropdown.Option>
        <Dropdown.Option value="banana">Banana</Dropdown.Option>
        <Dropdown.Option value="cherry">Cherry</Dropdown.Option>
        <Dropdown.Option value="date">Date</Dropdown.Option>
      </Dropdown>
    </Field>
  ),
};

Active Option Preview

Active option: none

export const ActiveOptionPreview: Story = {
  args: {
    placeholder: 'Select an option',
    onActiveOptionChange: fn(),
  },
  render: (args) => <ActiveOptionPreviewDropdown {...args} />,
};

Custom Expand Icon

export const CustomExpandIcon: Story = {
  args: {
    defaultValue: 'dog',
    expandIcon: <span aria-hidden>▾</span>,
  },
  render: (args) => (
    <Dropdown {...args}>
      <Dropdown.Option value="cat">Cat</Dropdown.Option>
      <Dropdown.Option value="dog">Dog</Dropdown.Option>
      <Dropdown.Option value="fish">Fish</Dropdown.Option>
    </Dropdown>
  ),
};

Rendered Value

export const RenderedValue: Story = {
  args: {
    defaultValue: 'dog',
    renderValue: (value: string) => (
      <span className="inline-flex items-center gap-1.5">
        <span aria-hidden className="size-2 shrink-0 rounded-full bg-wave-success" />
        <span className="capitalize">{value}</span>
      </span>
    ),
  },
  render: (args) => (
    <Dropdown {...args}>
      <Dropdown.Option value="cat">Cat</Dropdown.Option>
      <Dropdown.Option value="dog">Dog</Dropdown.Option>
      <Dropdown.Option value="fish">Fish</Dropdown.Option>
    </Dropdown>
  ),
};

Disabled Options

export const DisabledOptions: Story = {
  args: {
    disabledOptionsFocusable: true,
    placeholder: 'Select an animal',
  },
  render: (args) => (
    <Dropdown {...args}>
      <Dropdown.Option value="cat">Cat</Dropdown.Option>
      <Dropdown.Option value="dog" disabled>
        Dog (not available)
      </Dropdown.Option>
      <Dropdown.Option value="fish">Fish</Dropdown.Option>
    </Dropdown>
  ),
};

Invalid

export const Invalid: Story = {
  args: {
    'aria-label': undefined,
    placeholder: 'Select a pet',
  },
  render: (args) => (
    <Field label="Pet" error="Choose a pet." required>
      <Dropdown {...args}>
        <Dropdown.Option value="cat">Cat</Dropdown.Option>
        <Dropdown.Option value="dog">Dog</Dropdown.Option>
      </Dropdown>
    </Field>
  ),
};

Data Mode

export const DataMode: Story = {
  args: {
    'aria-label': 'Person',
    placeholder: 'Select a person',
    defaultValue: 'person-321',
    items: PEOPLE,
    renderOption: renderPerson,
  },
  argTypes: {
    items: { control: false },
    renderOption: { control: false },
    virtualWindow: { control: false },
  },
};

Ten Thousand Options

Mounted options: 0 of 10,000

export const TenThousandOptions: StoryObj<TenThousandOptionsArgs> = {
  args: {
    'aria-label': 'Person',
    placeholder: 'Select a person',
    defaultValue: 'person-5000',
    renderOption: renderPerson,
    itemSize: 32,
    style: { width: 360 },
  },
  argTypes: {
    items: { control: false },
    renderOption: { control: false },
    virtualWindow: { control: false },
    // Heights an option fits in; a smaller one would overlap the options.
    itemSize: { control: 'select', options: [32, 40, 48] },
  },
  render: (args) => <TenThousandDropdown {...args} />,
};

Ten Thousand Grouped Options

Mounted options: 0 of 10,000

export const TenThousandGroupedOptions: StoryObj<TenThousandOptionsArgs> = {
  args: {
    'aria-label': 'Person',
    placeholder: 'Select a person',
    defaultValue: 'person-5000',
    itemSize: 32,
    style: { width: 320 },
  },
  argTypes: {
    items: { control: false },
    renderOption: { control: false },
    renderGroup: { control: false },
    virtualWindow: { control: false },
    itemSize: { control: 'select', options: [32, 40, 48] },
  },
  render: (args) => <TenThousandGroupedDropdown {...args} />,
};

Sizes And Appearances

export const SizesAndAppearances: Story = {
  render: (args) => (
    <SizeAppearanceGrid
      render={(size, appearance) => (
        <Dropdown
          {...args}
          size={size}
          appearance={appearance}
          clearable
          defaultValue="user"
          aria-label={`${size} ${appearance}`}
        >
          <Dropdown.Option value="admin">Admin</Dropdown.Option>
          <Dropdown.Option value="user">User</Dropdown.Option>
        </Dropdown>
      )}
    />
  ),
};

Motion

export const Motion: Story = {
  render: function MotionPopups(args) {
    return (
      <div className="flex flex-wrap gap-4">
        {motionCases(fadeAndZoom).map(({ label, motion }) => (
          <Dropdown key={label} {...args} aria-label={label} motion={motion} placeholder={label}>
            <Option value="cat">Cat</Option>
            <Option value="dog">Dog</Option>
            <Option value="fish">Fish</Option>
          </Dropdown>
        ))}
      </div>
    );
  },
};

Props

NameTypeRequiredDefaultDescription
multiselectbooleanNofalse

Several options can be selected (Fluent's multiselect): the value is an array, options show a checkbox, Enter and Space toggle the highlighted option, a click toggles the clicked option, the list stays open, and each toggle is announced. A non-literal multiselect={flag} is a type error: render two elements, one for each mode.

valuereadonly string[] | stringNo

Controlled selected value ('' for none), or with multiselect the selected values (Fluent's selectedOptions).

defaultValuereadonly string[] | stringNo'' (`[]` with `multiselect`)

Initial selected value for uncontrolled usage.

onValueChange((value: string[]) => void) | ((value: string) => void)No

Called with the new value when it changes (a new array with multiselect; Fluent's onOptionSelect, under WaveUI's value/onValueChange naming).

openbooleanNo

Controlled open state of the listbox. The list renders only in the browser: an open dropdown is closed in the server HTML and opens once it has hydrated.

defaultOpenbooleanNofalse

Initial open state for uncontrolled usage. A dropdown that starts disabled starts closed. The list renders only in the browser: it is closed in the server HTML and opens once the dropdown has hydrated.

onOpenChange(open: boolean) => voidNo

Called when the listbox opens or closes.

onActiveOptionChange(value: string | null) => voidNo

Called after the active (highlighted) option changes — opening, arrow keys, typeahead, the pointer — and with null when the list closes. It reports what aria-activedescendant points at, from an effect once the change commits. Fluent's onActiveOptionChange reports neither the pointer (its options have no hover highlight) nor the close.

disabledOptionsFocusablebooleanNofalse

Keeps disabled options in the arrow-key, Home/End, PageUp/PageDown and typeahead order (the highlighted-by-default option may then be a disabled one too); they still cannot be selected (Enter, Space and a click do nothing and the list stays open), and in single-select mode, reaching one with Tab or Alt+ArrowUp closes the list without selecting it. Unlike Fluent, which always keeps disabled options reachable, WaveUI skips them by default.

placeholderstringNo'Select an option'

Placeholder text shown when no value is selected. It is not an accessible name: label the Dropdown with a Field, aria-label or aria-labelledby.

renderValue((value: string[]) => ReactNode) | ((value: string) => ReactNode)Nothe selected label (`labels.selection` with `multiselect`)

Renders the button's content while a value is selected (the placeholder shows otherwise), in place of the selected label (labels.selection with multiselect). It receives the raw value(s), never a label; the content must be non-interactive, and its text is the combobox's value, so image-only content leaves the value empty.

disabledbooleanNofalse

Whether the dropdown is disabled and non-interactive. Turning it on while the listbox is open closes it (onOpenChange(false)).

size'small' | 'medium' | 'large'No

Size of the field: small (24px tall), medium (32px) or large (40px). Default: the surrounding Field's size, else WaveProvider inputDefaults.size, else 'medium'. The listbox keeps its size; the multi-select value text and clear button follow it.

positioningPopupPositioningOptionsNo`{ matchReferenceWidth: true, fitViewport: true }`

Advanced positioning of the popup (Fluent's positioning): offset, fitViewport, matchReferenceWidth and fallbackPlacements (tried in order when the requested side has no room). The popup opens below the field.

motionMotionSlot | nullNothe fade and slide above

The popup surface's motion. By default it fades in and slides 4px away from the dropdown button, on the side it opened on, over 200 ms with a decelerating curve, and fades out and slides back over 100 ms with an accelerating curve (the list stays in the surface while it exits); under reduced motion it appears and disappears at once. The list does not fade out when its options changed as it closed (a filter reset by the selection), nor does the "No matches" row. null turns the motion off (the surface still renders its data-presence phases, which then end at once); a class string or { className } replaces the default classes with yours (see MotionSlot), also under a WaveProvider with motion="none", which otherwise turns the default off. Fluent's popup surfaceMotion.

appearance'outline' | 'underline' | 'filled-darker' | 'filled-lighter'No

Look of the field: outline (a full border), underline (a bottom stroke only), filled-darker or filled-lighter (a fill without a visible stroke: give the field a visible label). Default: WaveProvider inputDefaults.appearance, else 'outline'.

namestringNo

Name of the value in form submissions (renders a hidden input; one per value with multiselect).

formstringNo

Id of the form the value belongs to, when the Dropdown is outside it.

requiredbooleanNo

A value is required to submit the form (native constraint validation).

clearablebooleanNofalse

Shows a clear button while a value is selected (shown disabled while disabled). It clears the value (every value with multiselect), closes the list and moves focus to the combobox button. It is a tab stop after it.

expandIconSlot<'span'>No

The glyph at the end of the button (default: a chevron). null or undefined keep it; false, or a value that renders nothing, hides it (the button's end padding follows, together with clearable). The default chevron's size and the glyph's offset follow size. Decorative content rendered inside the button: a <button> or Button passed here is not nested (its children become the glyph, with a development warning).

labelsDropdownLabelsNo

The clear button's name and, with multiselect, the selected-labels text and the toggle announcements, for localization. Unset members keep their English defaults.

itemsreadonly ListboxItem[]No

Data mode: the options as data, in list order (value, label, and optionally textValue, disabled, hidden and group; values unique). Adjacent items with the same group are drawn as a named group under a header (renderGroup), the options of the group counting aria-posinset and aria-setsize among themselves. The open list renders one option per item that is not hidden (see renderOption); the closed list renders none. The keys, typeahead, the selection and the button's label text follow items, also for a selected item whose option is not rendered. The children are neither read nor rendered: passing both warns once in development. Each option gets aria-posinset and aria-setsize from its place among the shown items, and keeps one id per value. Without it, the options are the Option children.

renderOption(item: ListboxItem, state: ListboxOptionRenderState) => React.ReactNodeNoan `Option` with the item's `value`, `label` (also its text), `textValue` and `disabled`

Data mode: renders the option of an item, given its state (selected, active, and index among the shown options). Return an Option, or an option component of your own on useListboxOption, with the item's value (and its disabled); its position is set for you, and in a windowed list (virtualWindow) its height. It is called again only when the item, its state, its position (aria-posinset and aria-setsize, which new items change) or the function itself changes, so pass a stable function in a long list. Ignored without items, with a development warning.

renderGroup(group: string, state: ListboxGroupRenderState) => React.ReactNodeNothe group's name, as text

Data mode: renders the header of a group of items (those with the same group, next to each other), given the group's name and its state (index among the groups, size: its shown options). Return text or a few inline elements: the header is a row of the list, not an option, so nothing in it is reachable, and it is out of the accessibility tree (aria-hidden): the group's list is named by its name. In a list with a virtualWindow the header is a row of the window (as tall as an option, or measured with measureItems) and is not sticky: it scrolls away with its group. It is called again when the group's name, index or size changes or the function itself changes. Ignored without items, with a development warning.

virtualWindowVirtualWindowNo

Data mode: renders only the options in view of a long list, plus an overscan, and spacers (aria-hidden, data-virtual-spacer) as tall as the options they stand for: pass the result of useVirtualWindow({ itemSize }), or an object of your own that implements VirtualWindow. It needs items: without them, or beside OptionGroup children, it is ignored with a development warning (a window cannot read the options of children). Items with a group are windowed with their headers, which are rows of the window (itemSize tall, or measured with measureItems) and scroll away with their group: they are not sticky.

The open popup's list is the window's scroller, so it needs no height of yours: it scrolls within its own maximum height (15rem, 240 pixels at the default root size, less where the viewport has no room). Every option is exactly itemSize tall (the list sets its height, after the option's own style), so an option's content must fit in it: the default Option with one line of text is 32 pixels tall. With a window that measures its rows (useVirtualWindow({ itemSize, measureItems: true }), itemSize being the estimate) an option has the height of its content instead, and carries the window's itemProps.

The window counts the shown options (the items that are not hidden). The keys and typeahead move over all of them (Home and End to the first and the last, PageUp and PageDown by ten); the active option stays rendered while it is scrolled away, so aria-activedescendant always names an element, and when a key makes it active the list and the window move to it in the same update. Opening the list scrolls the active option (the selected one, by default) to the middle of the list, and again once the popup's positioning has given the list its height (a short viewport) unless it was scrolled first. A closed list renders no option. The browser's scroll anchoring is off on a windowed list (the window lays the options out).

onFocusReact.FocusEventHandler<HTMLButtonElement>No

Called when the <button role="combobox"> receives focus (the root keeps other handlers).

onBlurReact.FocusEventHandler<HTMLButtonElement>No

Called when the <button role="combobox"> loses focus.

onKeyDownReact.KeyboardEventHandler<HTMLButtonElement>No

Called on a key press on the <button role="combobox">, before the built-in listbox keys; event.preventDefault() skips them.

onKeyUpReact.KeyboardEventHandler<HTMLButtonElement>No

Called when a key is released on the <button role="combobox">.

refReact.Ref<HTMLButtonElement>No

Ref to the <button role="combobox">, the focusable control (Fluent UI's ref, on its primary element). The root <div> is slotProps.root.ref.

slotProps{ root?: SlotPart<'div'>; button?: SlotPart<'button'>; value?: SlotPart<'span'>; clearButton?: SlotPart<'button'>; listbox?: SlotPart<'ul'>; surface?: SlotPart<'div'> }No

Props for the elements the Dropdown draws, by part, merged into each part's own (Fluent UI's root, button, clearButton and listbox slot props): your classes after the part's (yours win a conflict), your styles over its styles, your handlers before its handlers (preventDefault() in yours skips the Dropdown's handling of the event, its own on… prop included), your ref beside its ref, and your ids added to its aria-labelledby and aria-describedby. Every attribute the Dropdown sets on a part is locked and keeps the Dropdown's value (set it through its own props); you add the attributes it does not set. A part takes no children. The options are Options, which take their own props.

Any other prop is passed to the element it renders (HTMLDivElement).

Parts

  • root
  • button
  • value
  • clearButton
  • listbox
  • surface
  • Dropdown.Option
  • Dropdown.OptionGroup

Stable class names

PartClass
rootwave-dropdown
buttonwave-dropdown__button
valuewave-dropdown__value
expandIconwave-dropdown__expand-icon
clearButtonwave-dropdown__clear-button
listboxwave-dropdown__listbox
surfacewave-dropdown__surface
spacerwave-dropdown__spacer