Beta v0.6.2

Dropdown Select

Dropdown Select components are used for collecting user provided information from a list of options.

Import


import { DropdownSelect } from "pier-ui";

Single Select


import React, { useState } from "react";
import { DropdownSelect } from "@pier-ui";
const Example = () => {
const [selected, setSelected] = useState({});
const options = [
{ label: "Grapes", value: "grapes" },
{ label: "Mango", value: "mango" },
{ label: "Strawberry", value: "strawberry" },
];
const selectChange = (list) => {
setSelected(list);
};
return (
<>
<div className="wrap">
<DropdownSelect
options={options}
value={selected}
onChange={selectChange}
label="Single select"
placeholder="Select"
className="custom-class"
closeOnChange={true}
/>
</div>
<style jsx>{`
.wrap {
padding: 30px 0px;
}
`}</style>
</>
); };
export default Example;


Multi Select


import React, { useState } from "react";
import { DropdownSelect } from "@pier-ui";
const ExampleDropdownSelectMultiple = () => {
const [selected, setSelected] = useState([]);
const options = [
{ label: "Grapes", value: "grapes" },
{ label: "Mango", value: "mango" },
{ label: "Strawberry", value: "strawberry" },
];
const selectChange = (list) => {
setSelected(list);
};
return (
<>
<div className="wrap">
<DropdownSelect
multiple
options={options}
value={selected}
onChange={selectChange}
label="Multi select"
placeholder="Select"
className="custom-class"
/>
</div>
<style jsx>{`
.wrap {
padding: 15px 0px 20px;
}
`}</style>
</>
);
};
export default ExampleDropdownSelectMultiple;

Props

PropDescriptionTypeDefault
classNameclassName for the componentstring
optionsOptions for the select (is required)array
valuepre-selected option ListboxSelect (is required){ label:, value: } [{ label:, value: }]
labelLabel for dropdownstring
floatingLabelfloatingLabelbooleanfalse
placeholderplaceholder for the dropdownstring
sizeSize of the dropdown: "base", "sm", "md", "lg"stringbase
colorColor of the dropdownstringtheme.colors.grey
focusColorColor of the dropdownstringtheme.colors.primary
closeOnChangeWhether the dropdown closes when a selection is made.booleanfalse
disabledbooleanfalse
requiredbooleanfalse
readOnlybooleanfalse
multipleRender the Multi Select Dropdownbooleanfalse
variantVariant of the dropdown: "outline", "filled"stringoutline
widthWidth of the dropdownstring