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
- Cat
- Dog
- Fish
- Hamster
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
- Cat
- Dog
- Fish
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
- Cat
- Dog
- Fish
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
- Mammals
- Cat
- Dog
- Fish
- Goldfish
- Shark (not available)
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
- Alpha
export const Disabled: Story = {
args: {
disabled: true,
placeholder: 'Disabled',
},
render: (args) => (
<Dropdown {...args}>
<Dropdown.Option value="a">Alpha</Dropdown.Option>
</Dropdown>
),
};Multiselect
- Apple
- Banana
- Cherry
- Date
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
- Cat
- Dog
- Fish
- Hamster
Active option: none
export const ActiveOptionPreview: Story = {
args: {
placeholder: 'Select an option',
onActiveOptionChange: fn(),
},
render: (args) => <ActiveOptionPreviewDropdown {...args} />,
};Custom Expand Icon
- Cat
- Dog
- Fish
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
- Cat
- Dog
- Fish
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
- Cat
- Dog (not available)
- Fish
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
- Cat
- Dog
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
- Admin
- User
- Admin
- User
- Admin
- User
- Admin
- User
- Admin
- User
- Admin
- User
- Admin
- User
- Admin
- User
- Admin
- User
- Admin
- User
- Admin
- User
- Admin
- User
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
- Cat
- Dog
- Fish
- Cat
- Dog
- Fish
- Cat
- Dog
- Fish
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
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
multiselect | boolean | No | false | Several options can be selected (Fluent's |
value | readonly string[] | string | No | Controlled selected value ( | |
defaultValue | readonly string[] | string | No | '' (`[]` 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 | |
open | boolean | No | 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. | |
defaultOpen | boolean | No | false | 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) => void | No | Called when the listbox opens or closes. | |
onActiveOptionChange | (value: string | null) => void | No | Called after the active (highlighted) option changes — opening, arrow keys, typeahead, the pointer — and with | |
disabledOptionsFocusable | boolean | No | false | 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. |
placeholder | string | No | 'Select an option' | Placeholder text shown when no value is selected. It is not an accessible name: label the Dropdown with a |
renderValue | ((value: string[]) => ReactNode) | ((value: string) => ReactNode) | No | the 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 ( |
disabled | boolean | No | false | Whether the dropdown is disabled and non-interactive. Turning it on while the listbox is open closes it ( |
size | 'small' | 'medium' | 'large' | No | Size of the field: | |
positioning | PopupPositioningOptions | No | `{ matchReferenceWidth: true, fitViewport: true }` | Advanced positioning of the popup (Fluent's |
motion | MotionSlot | null | No | the 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. |
appearance | 'outline' | 'underline' | 'filled-darker' | 'filled-lighter' | No | Look of the field: | |
name | string | No | Name of the value in form submissions (renders a hidden input; one per value with | |
form | string | No | Id of the form the value belongs to, when the Dropdown is outside it. | |
required | boolean | No | A value is required to submit the form (native constraint validation). | |
clearable | boolean | No | false | Shows a clear button while a value is selected (shown disabled while |
expandIcon | Slot<'span'> | No | The glyph at the end of the button (default: a chevron). | |
labels | DropdownLabels | No | The clear button's name and, with | |
items | readonly ListboxItem[] | No | Data mode: the options as data, in list order ( | |
renderOption | (item: ListboxItem, state: ListboxOptionRenderState) => React.ReactNode | No | an `Option` with the item's `value`, `label` (also its text), `textValue` and `disabled` | Data mode: renders the option of an item, given its state ( |
renderGroup | (group: string, state: ListboxGroupRenderState) => React.ReactNode | No | the group's name, as text | Data mode: renders the header of a group of |
virtualWindow | VirtualWindow | No | Data mode: renders only the options in view of a long list, plus an overscan, and spacers ( 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 The window counts the shown options (the items that are not | |
onFocus | React.FocusEventHandler<HTMLButtonElement> | No | Called when the | |
onBlur | React.FocusEventHandler<HTMLButtonElement> | No | Called when the | |
onKeyDown | React.KeyboardEventHandler<HTMLButtonElement> | No | Called on a key press on the | |
onKeyUp | React.KeyboardEventHandler<HTMLButtonElement> | No | Called when a key is released on the | |
ref | React.Ref<HTMLButtonElement> | No | Ref to the | |
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 |
Any other prop is passed to the element it renders (HTMLDivElement).
Parts
rootbuttonvalueclearButtonlistboxsurfaceDropdown.OptionDropdown.OptionGroup
Stable class names
| Part | Class |
|---|---|
root | wave-dropdown |
button | wave-dropdown__button |
value | wave-dropdown__value |
expandIcon | wave-dropdown__expand-icon |
clearButton | wave-dropdown__clear-button |
listbox | wave-dropdown__listbox |
surface | wave-dropdown__surface |
spacer | wave-dropdown__spacer |