Skip to content

SelectInput

Used to pick a value from predefined options.

Please select your pet
// Import component
import {
createListCollection,
SelectInput,
type ListCollectionItem,
} from '@fintech-sandpit/ui/react';
// Import styles (optional). Please note that SelectInput is using Field and Select components.
import '@fintech-sandpit/ui/style/components/field.css';
import '@fintech-sandpit/ui/style/components/select.css';
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 (
<SelectInput
collection={collection}
label="Pet"
placeholder="Select a pet"
hint="Please select your pet"
error="Invalid pet"
/>
);
NameTypeDefaultDescription
valuestring[]—Controlled value of the select input
defaultValuestring[]—Default (uncontrolled) value of the select input
namestring—Name of the input element
collectionCollection—Options of the select input
orientationOrientationverticalOrientation of the select input
sizeSizemdSize of the select input
asNativebooleanfalseWhether the input is a native HTML select input
multiplebooleanfalseWhether the select input is multiple
labelstring—Label of the select input
hintstring—Helper text of the select input
errorstring—Error text of the select input
requiredbooleanfalseWhether the select input is required
invalidbooleanfalseWhether the select input is invalid
readOnlybooleanfalseWhether the select input is read only
disabledbooleanfalseWhether the select input is disabled
placeholderstring—Placeholder of the select input
NameTypeDescription
onValueChange(value: string[]) => voidCallback fired when the value changes
type Collection = ListCollection<ListCollectionItem>
type ListCollectionItem = {
label: string;
value: string;
disabled?: boolean;
group?: string;
}
type Orientation = 'horizontal' | 'vertical'
type Size = 'xs' | 'sm' | 'md' | 'lg' | 'xl'