Skip to content

SelectInput

Used to pick a value from predefined options.

// 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 | string[]—Controlled value of the select input 1
defaultValuestring | string[]—Default (uncontrolled) value of the select input 1
namestring—Name of the input element
collectionCollection—Options of the select input
orientationOrientationverticalOrientation of the select input
sizeSizemdSize of the 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
  1. The value type is string for single selection (multiple is false) and string[] for multiple selection (multiple is true).
NameTypeDescription
onValueChange(value: string | string[]) => voidCallback fired when the value changes 1
  1. The value type is string for single selection (multiple is false) and string[] for multiple selection (multiple is true).
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'