The select component gives the user user a way to choose one out of multiple options as an answer to a question.
Upon submition the formState gets assigned the selected objects from the options w.r.t it's name prop
// formState { pet: {label: 'Cat', value: 'cat'}}
In addition to the Common Props which are found in every data input element (Input, Select and MultiSelect) here are the props the Select component accepts.
Type | Description |
---|---|
[{label: string, value: string}] (Array of Object of the given type) | Array of options for user to choose from |
This is a required prop. The option prop accepts an array of Object of the following type
{label: string, value: string}
The Label contains the text to be shown to the user inside a button as an option. Sometimes the displayed label text isn't useful to work with, hence an alternate value is also provided.