Skip to content

Select

Displays a list of options for the user to pick from.

import {
createListCollection,
Select,
type ListCollectionItem,
} from '@fintech-sandpit/ui/react';
const collection = createListCollection<ListCollectionItem>({
items: [
{ label: 'Dog', value: 'dog', group: 'Mammals' },
{ label: 'Cat', value: 'cat', group: 'Mammals' },
{ label: 'Canary', value: 'canary', group: 'Birds' },
{ label: 'Parrot', value: 'parrot', group: 'Birds' },
{ label: 'Goldfish', value: 'goldfish', group: 'Aquatic' },
{ label: 'Turtle', value: 'turtle', group: 'Aquatic', disabled: true },
],
groupBy: item => item.group ?? '',
});
return (
<Select
collection={collection}
placeholder="Select a pet"
/>
);
NameTypeDefaultDescription
valuestring[]Controlled value of the select input
defaultValuestring[]Default (uncontrolled) value of the select input
collectionCollectionOptions of the select input
sizeSizemdSize of the select input
multiplebooleanfalseWhether the select input is multiple
clearablebooleanfalseWhether the select input is clearable (a ‘x’ icon is shown)
invalidbooleanfalseWhether the select input is invalid
readOnlybooleanfalseWhether the select input is read only
disabledbooleanfalseWhether the select input is disabled
placeholderstringPlaceholder of the select input
NameTypeDescription
onChange(value: string[]) => voidCallback fired when the value changes
type Collection = ListCollection<ListCollectionItem>
type ListCollectionItem = {
label: string;
value: string;
disabled?: boolean;
group?: string;
}
type Size = 'xs' | 'sm' | 'md' | 'lg' | 'xl'