enes

Dropdown

import { Dropdown } from 'fluentui-svelte';

The Dropdown lets users select one or more options from a list of DropdownOption children. Options can render rich content, such as a Persona, and the current selection is exposed through a bindable value.

Usage

<script>
	import { Dropdown, DropdownOption } from 'fluentui-svelte';
</script>

<Dropdown>
	<DropdownOption value="A" text="Option A">Option A</DropdownOption>
	<DropdownOption value="B" text="Option B">Option B</DropdownOption>
</Dropdown>

Custom Option Content

Options can render any content, such as a Persona. Pass a text prop so the closed dropdown can still display the selection.

Multiple Selection

Set the multiple prop to allow selecting more than one option at a time while pressing Ctrl (or Cmd on Mac).

Component Props

NameTypeDefaultDescription
value bindablestring | string[]multiple ? [] : ''The selected value. An array of values when `multiple` is set.
multiplebooleanAllows more than one option to be selected at a time.
placeholderstring'Select an option'The text shown by the trigger while no option is selected.
disabledbooleanDisables the user interaction.
namestring | nullidThe name submitted with the form. Falls back to the id of the dropdown.
ref bindableHTMLDivElementThe DOM reference of the dropdown element.
onclick(e: MouseEvent) => voidCalled when the dropdown is clicked.
wrapperPropsHTMLAttributesThe attributes to spread on the wrapper element.
buttonRef bindableHTMLButtonElementThe DOM reference of the button that opens the dropdown.
buttonPropsHTMLButtonAttributesThe attributes to spread on the button that opens the dropdown.
inputRefHTMLInputElementThe DOM reference of the hidden input holding the value.
flyoutRef bindableHTMLDivElementThe DOM reference of the flyout element.
flyoutPropsFlyoutPropsThe props to spread on the flyout.
flyoutMaxHeightstringThe maximum height of the flyout, as a CSS length.
listboxRef bindableHTMLUListElementThe DOM reference of the listbox element.
listboxPropsListViewPropsThe props to spread on the listbox rendered inside the flyout.
DropdownMultipleValue | DropdownSingleValue
HTMLInputAttributes without value, onclick

DropdownOption Props

NameTypeDefaultDescription
textstringThe text shown by the dropdown once the option is selected. Falls back to the rendered children.
ListViewItemProps<'li'>