This kit's options prop requires an array of objects, each of which will be used as the selectable options within the dropdown. Each option object can support any number of key-value pairs, but each must contain label and value.
import React from 'react' import { Dropdown } from 'playbook-ui' const DropdownDefault = (props) => { const options = [ { label: "United States", value: "unitedStates", id: "us" }, { label: "Canada", value: "canada", id: "ca" }, { label: "Pakistan", value: "pakistan", id: "pk" } ]; return ( <div> <Dropdown options={options} /> </div> ) } export default DropdownDefault
The autocomplete prop can be used to add autocomplete or typeahead functionality to the Dropdown's default Trigger. This prop is set to 'false' by default.
import React from 'react' import { Dropdown } from 'playbook-ui' const DropdownWithAutocomplete = (props) => { const options = [ { label: "United States", value: "unitedStates", areaCode: "+1", icon: "🇺🇸", id: "us" }, { label: "United Kingdom", value: "unitedKingdom", areaCode: "+44", icon: "🇬🇧", id: "gb" }, { label: "Pakistan", value: "pakistan", areaCode: "+92", icon: "🇵🇰", id: "pk" } ] return ( <div> <Dropdown autocomplete options={options} /> </div> ) } export default DropdownWithAutocomplete
multiSelect is a boolean prop that if set to true will allow for multiple options to be selected from the Dropdown.
multiSelect is set to false by default.
import React from 'react' import { Dropdown } from 'playbook-ui' const DropdownMultiSelect = (props) => { const options = [ { label: "United States", value: "unitedStates", id: "us" }, { label: "United Kingdom", value: "unitedKingdom", id: "gb" }, { label: "Canada", value: "canada", id: "ca" }, { label: "Pakistan", value: "pakistan", id: "pk" }, { label: "India", value: "india", id: "in" }, { label: "Australia", value: "australia", id: "au" }, { label: "New Zealand", value: "new Zealand", id: "nz" }, { label: "Italy", value: "italy", id: "it" }, { label: "Spain", value: "spain", id: "es" } ]; return ( <div> <Dropdown multiSelect options={options} /> </div> ) } export default DropdownMultiSelect
multiSelect can also be used with the autocomplete functionality.
import React from 'react' import { Dropdown } from 'playbook-ui' const DropdownMultiSelectWithAutocomplete = (props) => { const options = [ { label: "United States", value: "unitedStates", id: "us" }, { label: "United Kingdom", value: "unitedKingdom", id: "gb" }, { label: "Canada", value: "canada", id: "ca" }, { label: "Pakistan", value: "pakistan", id: "pk" }, { label: "India", value: "india", id: "in" }, { label: "Australia", value: "australia", id: "au" }, { label: "New Zealand", value: "new Zealand", id: "nz" }, { label: "Italy", value: "italy", id: "it" }, { label: "Spain", value: "spain", id: "es" } ]; return ( <div> <Dropdown autocomplete multiSelect options={options} /> </div> ) } export default DropdownMultiSelectWithAutocomplete
By default, the multiSelect prop will render selected options as the default FormPill. FormPillProps however can be used to customize these Pills with any props that exist for the FormPill.
This prop must be an object that contains valid FormPill props. For a full list of FormPill props, see here.
import React from 'react' import { Dropdown } from 'playbook-ui' const DropdownMultiSelectDisplay = (props) => { const options = [ { label: "United States", value: "unitedStates", id: "us" }, { label: "United Kingdom", value: "unitedKingdom", id: "gb" }, { label: "Canada", value: "canada", id: "ca" }, { label: "Pakistan", value: "pakistan", id: "pk" }, { label: "India", value: "india", id: "in" }, { label: "Australia", value: "australia", id: "au" }, { label: "New Zealand", value: "new Zealand", id: "nz" }, { label: "Italy", value: "italy", id: "it" }, { label: "Spain", value: "spain", id: "es" } ]; return ( <div> <Dropdown formPillProps={{size:"small", color:"neutral"}} multiSelect options={options} /> </div> ) } export default DropdownMultiSelectDisplay
For the subtle variant, it is recommended that you set the Separators prop to false to remove the separator lines between the options for a cleaner look.
import React from 'react' import { Dropdown } from 'playbook-ui' const DropdownSubtleVariant = (props) => { const options = [ { label: "United States", value: "unitedStates", id: "us" }, { label: "Canada", value: "canada", id: "ca" }, { label: "Pakistan", value: "pakistan", id: "pk" } ]; return ( <> <Dropdown options={options} separators={false} variant="subtle" /> </> ) } export default DropdownSubtleVariant
The dropdown is built using all of the following subcomponents:
Dropdown.Trigger is the UI component that users interact with to toggle the dropdown.
Dropdown.Container is the floating container that wraps the list of dropdown options.
Dropdown.Option renders options that are passed to the container.
Each of these subcomponents can be altered using global props and/or their respective props. See doc examples below for more information on each.
import React from 'react' import { Dropdown } from 'playbook-ui' const DropdownSubcomponentStructure = (props) => { const options = [ { label: "United States", value: "unitedStates", id: "us" }, { label: "Canada", value: "canada", id: "ca" }, { label: "Pakistan", value: "pakistan", id: "pk" } ]; return ( <div> <Dropdown options={options} > <Dropdown.Trigger/> <Dropdown.Container> {options.map((option) => ( <Dropdown.Option key={option.id} option={option} /> ))} </Dropdown.Container> </Dropdown> </div> ) } export default DropdownSubcomponentStructure
autocomplete prop can also be used in conjunction with the subcomponent structure.
import React from 'react' import { Dropdown, Badge, Flex, FlexItem, User } from 'playbook-ui' const DropdownWithAutocompleteWithSubcomponents = (props) => { const options = [ { label: "Jasper Furniss", value: "jasperFurniss", territory: "PHL", title: "Lead UX Engineer", id: "jasper-furniss", status: "Offline" }, { label: "Ramon Ruiz", value: "ramonRuiz", territory: "PHL", title: "Senior UX Designer", id: "ramon-ruiz", status: "Away" }, { label: "Carlos Lima", value: "carlosLima", territory: "PHL", title: "Nitro Developer", id: "carlos-lima", status: "Online" }, { label: "Courtney Long", value: "courtneyLong", territory: "PHL", title: "Lead UX Designer", id: "courtney-long", status: "Online" } ]; return ( <div> <Dropdown autocomplete options={options} > {options.map((option) => ( <Dropdown.Option key={option.id} option={option} > <Flex align="center" justify="between" > <FlexItem> <User align="left" avatar name={option.label} orientation="horizontal" territory={option.territory} title={option.title} /> </FlexItem> <FlexItem> <Badge dark rounded text={option.status} variant={`${ option.status === "Offline" ? "neutral" : option.status === "Online" ? "success" : "warning" }`} /> </FlexItem> </Flex> </Dropdown.Option> ))} </Dropdown> </div> ) } export default DropdownWithAutocompleteWithSubcomponents
The top-level Dropdown component optionally accepts any string through a label prop to produce a label above your trigger element.
import React from 'react' import { Dropdown } from 'playbook-ui' const DropdownDefault = (props) => { const options = [ { label: "United States", value: "unitedStates", id: "us" }, { label: "Canada", value: "canada", id: "ca" }, { label: "Pakistan", value: "pakistan", id: "pk" } ]; return ( <div> <Dropdown label="Select a Country" options={options} > {options.map((option) => ( <Dropdown.Option key={option.id} option={option} /> ))} </Dropdown> </div> ) } export default DropdownDefault
Dropdown.Option subcomponent accepts any child components to customize the options' contents and display. By default, options are Body kit text that is set by the label value from the option object.
import React from 'react' import { Dropdown, FlexItem, Icon, Body, Flex } from 'playbook-ui' const DropdownWithCustomOptions = (props) => { const options = [ { label: "United States", value: "unitedStates", areaCode: "+1", icon: "🇺🇸", id: "United-states" }, { label: "Canada", value: "canada", areaCode: "+1", icon: "🇨🇦", id: "canada" }, { label: "Pakistan", value: "pakistan", areaCode: "+92", icon: "🇵🇰", id: "pakistan" } ]; return ( <div> <Dropdown options={options} > {options.map((option) => ( <Dropdown.Option key={option.id} option={option} > <Flex align="center" justify="between" > <FlexItem> <Flex> <Icon icon={option.icon} paddingRight="xs" /> <Body text={option.label} /> </Flex> </FlexItem> <FlexItem> <Body color="light" text={option.areaCode} /> </FlexItem> </Flex> </Dropdown.Option> ))} </Dropdown> </div> ) } export default DropdownWithCustomOptions
import React from 'react' import { Dropdown, Body, Flex, FlexItem, Icon } from 'playbook-ui' const DropdownMultiSelectWithCustomOptions = (props) => { const options = [ { label: "United States", value: "unitedStates", areaCode: "+1", icon: "🇺🇸", id: "United-states" }, { label: "Canada", value: "canada", areaCode: "+1", icon: "🇨🇦", id: "canada" }, { label: "Pakistan", value: "pakistan", areaCode: "+92", icon: "🇵🇰", id: "pakistan" }, { label: "India", value: "india", areaCode: "+91", icon: "🇮🇳", id: "india" }, { label: "Australia", value: "australia", areaCode: "+61", icon: "🇦🇺", id: "australia" }, { label: "New Zealand", value: "newZealand", areaCode: "+64", icon: "🇳🇿", id: "new-zealand" }, { label: "Italy", value: "italy", areaCode: "+39", icon: "🇮🇹", id: "italy" }, { label: "Spain", value: "spain", areaCode: "+34", icon: "🇪🇸", id: "spain" } ]; return ( <div> <Dropdown multiSelect options={options} > {options.map((option) => ( <Dropdown.Option key={option.id} option={option} > <Flex align="center" justify="between" > <FlexItem> <Flex> <Icon icon={option.icon} paddingRight="xs" /> <Body text={option.label} /> </Flex> </FlexItem> <FlexItem> <Body color="light" text={option.areaCode} /> </FlexItem> </Flex> </Dropdown.Option> ))} </Dropdown> </div> ) } export default DropdownMultiSelectWithCustomOptions
Optionally utilize customDisplay on the Dropdown.Trigger subcomponent to customize its content after an option is selected. Pass in any combination of kits to create a custom display. When a user clicks on an option, the kits passed into customDisplay will display as the selected option.
The placeholder prop can also be used to customize the placeholder text for the default Dropdown.Trigger.
The onSelect prop returns the selected option as an object to be utilized by the dev. In this example we are using the onSelect to set a state with the selected option and using it to customize the customDisplay.
import React, { useState } from 'react' import { Dropdown, Badge, Flex, FlexItem, Avatar, User, Body } from 'playbook-ui' const DropdownWithCustomDisplay = (props) => { const [selectedOption, setSelectedOption] = useState(); const options = [ { label: "Jasper Furniss", value: "jasperFurniss", territory: "PHL", title: "Lead UX Engineer", id: "jasper-furniss", status: "Offline" }, { label: "Ramon Ruiz", value: "ramonRuiz", territory: "PHL", title: "Senior UX Designer", id: "ramon-ruiz", status: "Away" }, { label: "Carlos Lima", value: "carlosLima", territory: "PHL", title: "Nitro Developer", id: "carlos-lima", status: "Online" }, { label: "Courtney Long", value: "courtneyLong", territory: "PHL", title: "Lead UX Designer", id: "courtney-long", status: "Online" } ]; const CustomDisplay = () => { return ( <> { selectedOption && ( <Flex align="center"> <Avatar name={selectedOption.label} size="xs" /> <Body marginX="xs" text={selectedOption.label} /> <Badge text={selectedOption.status} variant={selectedOption.status == "Offline" ? "neutral" : selectedOption.status == "Online" ? "success" : "warning"} /> </Flex> ) } </> ) }; return ( <div> <Dropdown onSelect={(selectedItem) => setSelectedOption(selectedItem)} options={options} > <Dropdown.Trigger customDisplay={<CustomDisplay/>} placeholder="Select a User" /> {options.map((option) => ( <Dropdown.Option key={option.id} option={option} > <Flex align="center" justify="between" > <FlexItem> <User align="left" avatar name={option.label} orientation="horizontal" territory={option.territory} title={option.title} /> </FlexItem> <FlexItem> <Badge dark rounded text={option.status} variant={`${ option.status === "Offline" ? "neutral" : option.status === "Online" ? "success" : "warning" }`} /> </FlexItem> </Flex> </Dropdown.Option> ))} </Dropdown> </div> ) } export default DropdownWithCustomDisplay
Optionally replace the default trigger's select element by passing child components directly to the Dropdown.Trigger.
import React, { useState } from 'react' import { Dropdown, FlexItem, Icon, Body, Flex, IconCircle } from 'playbook-ui' const DropdownWithCustomTrigger = (props) => { const [selectedOption, setSelectedOption] = useState(); const options = [ { label: "United States", value: "unitedStates", areaCode: "+1", icon: "🇺🇸", id: "United-states" }, { label: "Canada", value: "canada", areaCode: "+1", icon: "🇨🇦", id: "canada" }, { label: "Pakistan", value: "pakistan", areaCode: "+92", icon: "🇵🇰", id: "pakistan" } ]; return ( <div> <Dropdown onSelect={(selectedItem) => setSelectedOption(selectedItem)} options={options} > <Dropdown.Trigger> <div key={selectedOption ? selectedOption.icon : "flag"}> <IconCircle cursor="pointer" icon={selectedOption ? selectedOption.icon : "flag"} variant="royal" /> </div> </Dropdown.Trigger> <Dropdown.Container maxWidth="xs"> {options.map((option) => ( <Dropdown.Option key={option.id} option={option} > <Flex align="center" justify="between" > <FlexItem> <Flex> <Icon icon={option.icon} paddingRight="xs" /> <Body text={option.label} /> </Flex> </FlexItem> <FlexItem> <Body color="light" text={option.areaCode} /> </FlexItem> </Flex> </Dropdown.Option> ))} </Dropdown.Container> </Dropdown> </div> ) } export default DropdownWithCustomTrigger
The optional searchbar boolean prop can also be used on the Dropdown.Container to render a searchbar with typeahead functionality within the dropdown itself. This is especially useful when a custom trigger is being used.
searchbar is set to false by default.
import React, { useState } from 'react' import { Dropdown, IconCircle } from 'playbook-ui' const DropdownWithSearch = (props) => { const [selectedOption, setSelectedOption] = useState(); const options = [ { label: "United States", value: "unitedStates", icon: "🇺🇸", id: "United-states" }, { label: "United Kingdom", value: "unitedKingdom", icon: "🇬🇧", id: "united-kingdom" }, { label: "Pakistan", value: "pakistan", icon: "🇵🇰", id: "pakistan" } ]; return ( <div> <Dropdown onSelect={(selectedItem) => setSelectedOption(selectedItem)} options={options} > <Dropdown.Trigger> <div key={selectedOption ? selectedOption.icon : "flag"}> <IconCircle cursor="pointer" icon={selectedOption ? selectedOption.icon : "flag"} variant="royal" /> </div> </Dropdown.Trigger> <Dropdown.Container maxWidth="xs" searchbar > {options.map((option) => ( <Dropdown.Option key={option.id} option={option} /> ))} </Dropdown.Container> </Dropdown> </div> ) } export default DropdownWithSearch
By default, dropdown option paddingX is set to sm and paddingY is set to xs, but this padding can be overridden using our global padding props. In this example we are setting the option padding to sm all around.
import React from 'react' import { Dropdown } from 'playbook-ui' const DropdownWithCustomPadding = (props) => { const options = [ { label: "United States", value: "unitedStates", areaCode: "+1", icon: "🇺🇸", id: "United-states" }, { label: "Canada", value: "canada", areaCode: "+1", icon: "🇨🇦", id: "canada" }, { label: "Pakistan", value: "pakistan", areaCode: "+92", icon: "🇵🇰", id: "pakistan" } ]; return ( <div> <Dropdown options={options} > {options.map((option) => ( <Dropdown.Option key={option.id} option={option} padding="sm" /> ))} </Dropdown> </div> ) } export default DropdownWithCustomPadding
The activeStyle prop can be used to customize the appearance of the dropdown selection indicator. It accepts an object with the following keys: backgroundColor sets the background color of the selected item (and its hover state); fontColor sets the font color of the selected item.
backgroundColor Type: String | Values: bg_light | white | Default: (no selection) is primary
fontColor Type: String | Values: primary | all Playbook Text Colors | Default: (no selection) is white
import React from 'react' import { Dropdown } from 'playbook-ui' const DropdownCustomActiveStyleOptions = (props) => { const options = [ { label: "United States", value: "unitedStates", id: "us" }, { label: "Canada", value: "canada", id: "ca" }, { label: "Pakistan", value: "pakistan", id: "pk" } ]; return ( <div> <Dropdown activeStyle={{ backgroundColor: "bg_light", fontColor: "primary", }} label="Background Color: bg_light; Font Color: primary" marginBottom="sm" options={options} > <Dropdown.Trigger/> <Dropdown.Container> {options.map((option) => ( <Dropdown.Option key={option.id} option={option} /> ))} </Dropdown.Container> </Dropdown> <Dropdown activeStyle={{ backgroundColor: "white", fontColor: "primary", }} label="Background Color: white; Font Color: primary" marginBottom="sm" options={options} /> <Dropdown activeStyle={{ backgroundColor: "bg_light", fontColor: "text_lt_default", }} autocomplete label="Background Color: bg_light; Font Color: text_lt_default" marginBottom="sm" options={options} /> <Dropdown activeStyle={{ fontColor: "text_lt_lighter", }} label="Font Color: text_lt_lighter" marginBottom="sm" options={options} > <Dropdown.Trigger/> <Dropdown.Container> {options.map((option) => ( <Dropdown.Option key={option.id} option={option} /> ))} </Dropdown.Container> </Dropdown> </div> ) } export default DropdownCustomActiveStyleOptions
Use the Dropdown.Option subcomponent structure to include custom layouts inside dropdown menus. Icons can be placed alongside the Body label text.
import React from 'react' import { Dropdown, Body, Flex, Icon } from 'playbook-ui' const DropdownCustomIconOptions = (props) => { const options = [ { label: "Item 1", value: "item-1", id: "1" }, { label: "Item 2", value: "item-2", id: "2" }, { label: "Item 3", value: "item-3", id: "3" }, ] return ( <div> <Dropdown label="Multiple Icons" options={options} > {options.map((option) => ( <Dropdown.Option key={option.id} option={option} > <Flex align="center" justify="between" > <Flex align="center"> <Icon icon="calendar" paddingRight="xs" /> <Body color="default" text={option.label} /> </Flex> <Icon icon="check" /> </Flex> </Dropdown.Option> ))} </Dropdown> <Dropdown label="Icon on Left" options={options} paddingY="md" > {options.map((option) => ( <Dropdown.Option key={option.id} option={option} > <Flex align="center"> <Icon icon="calendar" paddingRight="xs" /> <Body color="default" text={option.label} /> </Flex> </Dropdown.Option> ))} </Dropdown> <Dropdown label="Icon on Right" options={options} > {options.map((option) => ( <Dropdown.Option key={option.id} option={option} > <Flex align="center" justify="between" > <Flex align="center"> <Body color="default" text={option.label} /> </Flex> <Icon icon="check" /> </Flex> </Dropdown.Option> ))} </Dropdown> </div> ) } export default DropdownCustomIconOptions
Radio inputs can be used inside Dropdown.Option for a custom layout that mimics form-like selection within a dropdown. Use the activeStyle backgroundColor and fontColor props to create contrast between the Radio selection indicator and the Dropdown selection background indicator.
import React, { useState } from 'react' import { Dropdown, Body, Flex, Radio } from 'playbook-ui' const DropdownCustomRadioOptions = (props) => { const [selectedValue, setSelectedValue] = useState(null) const options = [ { label: "Item 1", value: "item-1", id: "1" }, { label: "Item 2", value: "item-2", id: "2" }, { label: "Item 3", value: "item-3", id: "3" }, ] return ( <div> <Dropdown activeStyle={{ backgroundColor: "bg_light", fontColor: "text_lt_default" }} label="Select Item" onSelect={(selectedItem) => setSelectedValue(selectedItem?.value)} options={options} > {options.map((option) => { return ( <Dropdown.Option key={option.id} option={option} > <Flex align="center"> <Radio checked={selectedValue === option.value} name="dropdown_radio" value={option.value} /> <Body text={option.label} /> </Flex> </Dropdown.Option> ) })} </Dropdown> </div> ) } export default DropdownCustomRadioOptions
import React, { useState } from 'react' import { Dropdown, Icon } from 'playbook-ui' const DropdownError = (props) => { const [selectedOption, setSelectedOption] = useState() const error = selectedOption?.value ? null : (<> <Icon icon="warning" /> Please make a valid selection </>) const options = [ { label: "United States", value: "unitedStates", id: "us" }, { label: "Canada", value: "canada", id: "ca" }, { label: "Pakistan", value: "pakistan", id: "pk" } ]; return ( <> <Dropdown error={error} onSelect={(selectedItem) => setSelectedOption(selectedItem)} options={options} /> </> ) } export default DropdownError
import React from 'react' import { Dropdown } from 'playbook-ui' const DropdownDefaultValue = (props) => { const options = [ { label: "United States", value: "unitedStates", id: "us" }, { label: "Canada", value: "canada", id: "ca" }, { label: "Pakistan", value: "pakistan", id: "pk" } ]; return ( <> <Dropdown defaultValue={options[2]} options={options} /> </> ) } export default DropdownDefaultValue
import React from "react"; import { Dropdown } from 'playbook-ui' const DropdownMultiSelectWithDefault = (props) => { const options = [ { label: "United States", value: "unitedStates", id: "us" }, { label: "United Kingdom", value: "unitedKingdom", id: "gb" }, { label: "Canada", value: "canada", id: "ca" }, { label: "Pakistan", value: "pakistan", id: "pk" }, { label: "India", value: "india", id: "in" }, { label: "Australia", value: "australia", id: "au" }, { label: "New Zealand", value: "new Zealand", id: "nz" }, { label: "Italy", value: "italy", id: "it" }, { label: "Spain", value: "spain", id: "es" } ]; const defaultSelectedOptions = [ { label: "United States", value: "unitedStates", }, { label: "Italy", value: "italy", }, ]; return ( <div> <Dropdown defaultValue={defaultSelectedOptions} multiSelect options={options} /> </div> ); }; export default DropdownMultiSelectWithDefault;
import React from 'react' import { Dropdown } from 'playbook-ui' const DropdownBlankSelection = (props) => { const options = [ { label: "United States", value: "unitedStates", id: "us" }, { label: "Canada", value: "canada", id: "ca" }, { label: "Pakistan", value: "pakistan", id: "pk" } ]; return ( <> <Dropdown blankSelection="Select one..." options={options} /> </> ) } export default DropdownBlankSelection
To use an external control (like a reset button) to clear Dropdown selection, you can make use of the useRef hook. You must pass a ref to the Dropdown component and use that ref within the onClick for the external control in the way shown in the code snippet below.
import React, { useRef } from 'react' import { Button, Dropdown } from 'playbook-ui' const options = [ { label: "United States", value: "unitedStates", id: "us" }, { label: "Canada", value: "canada", id: "ca" }, { label: "Pakistan", value: "pakistan", id: "pk" } ] const DropdownClearSelection = (props) => { const dropdownRef = useRef(null) const handleReset = () => { if (dropdownRef.current) { dropdownRef.current.clearSelected() } } return ( <> <Dropdown defaultValue={options[2]} options={options} ref={dropdownRef} /> <Button marginTop="md" onClick={handleReset} text="Reset" /> </> ) } export default DropdownClearSelection
import React from 'react' import { Dropdown } from 'playbook-ui' const DropdownSeparatorsHidden = (props) => { const options = [ { label: "United States", value: "unitedStates", id: "us" }, { label: "Canada", value: "canada", id: "ca" }, { label: "Pakistan", value: "pakistan", id: "pk" } ]; return ( <div> <Dropdown options={options} separators={false} /> </div> ) } export default DropdownSeparatorsHidden
The useDropdown hook can also be used to toggle the dropdown open and closed using an external control. To do so, you must manage state with the custom hook, pass the dropdown:'pb-dropdown-trigger' data attribute to the external control and use the isClosed prop as shown.
import React from 'react' import { Dropdown, useDropdown, Button } from 'playbook-ui' const DropdownWithExternalControl = (props) => { const [isDropDownClosed, setIsDropdownClosed] = useDropdown(true); const options = [ { label: "United States", value: "unitedStates", areaCode: "+1", icon: "🇺🇸", id: "United-states" }, { label: "Canada", value: "canada", areaCode: "+1", icon: "🇨🇦", id: "canada" }, { label: "Pakistan", value: "pakistan", areaCode: "+92", icon: "🇵🇰", id: "pakistan" } ]; return ( <div> <Button data={{dropdown:'pb-dropdown-trigger'}} marginBottom='sm' onClick={() => setIsDropdownClosed(!isDropDownClosed)} padding="none" tabIndex={0} variant="link" > {isDropDownClosed ? "Open Dropdown" : "Close Dropdown"} </Button> <Dropdown isClosed={isDropDownClosed} options={options} > {options.map((option) => ( <Dropdown.Option key={option.id} option={option} /> ))} </Dropdown> </div> ) } export default DropdownWithExternalControl