Use the SelectMenu component
masterThe SelectMenu component is an advanced interaction pattern for selecting one or multiple items from a dropdown list. It is built on top of the Popover component and uses react-tiny-virtual-list for efficient rendering of large option lists. It can serve as a replacement for native multiple select elements.
function SingleSelectedItemExample() {
const [selected, setSelected] = React.useState(null)
return (
<SelectMenu
title="Select name"
options={['Apple', 'Apricot', 'Banana', 'Cherry', 'Cucumber'].map((label) => ({ label, value: label }))}
selected={selected}
onSelect={(item) => setSelected(item.value)}
>
<Button>{selected || 'Select name...'}</Button>
</SelectMenu>
)
}