Sha256: 589be77b425bad6dc6ec2db4c8dfab1658914aaf8e46ca1d65f6d3b0407aab51
Contents?: true
Size: 1.39 KB
Versions: 2
Compression:
Stored size: 1.39 KB
Contents
import React, { useState } from 'react' import { Dropdown, useDropdown, Button } from '../../' const DropdownWithExternalControl = (props) => { // eslint-disable-next-line no-unused-vars const [selectedOption, setSelectedOption] = useState(); const [isDropDownClosed, setIsDropdownClosed] = useDropdown(true); const options = [ { label: "United States", value: "United States", 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} onSelect={(selectedItem) => setSelectedOption(selectedItem)} options={options} {...props} > {options.map((option) => ( <Dropdown.Option key={option.id} option={option} /> ))} </Dropdown> </div> ) } export default DropdownWithExternalControl
Version data entries
2 entries across 2 versions & 2 rubygems