Skip to main content

Select

Props

NameTypeDefaultDescription
optionsarray[]List of options for the select/dropdown input. Each option should have a label and value.
namestring-Selects's name being registered field.
isDisabledboolean-Disables the input field when true.
idstring''The unique identifier for the select field.
labelstring''The label for the select field.
tooltipstring or ReactNode-Tooltip content to display additional information about the field.
fetchUrlstring''URL to fetch dynamic options for the select.
transformOptionsfunction() => [{ label: '', value: '' }]Function to transform fetched data into a compatible options array.

Select with static options

const countrySelectConfig = {
type: 'select',
data: {
id: 'country',
name: 'country',
label: 'Country *',
tooltip: 'Select your country of residence.',
options: [
{ label: 'United States', value: 'us' },
{ label: 'Canada', value: 'ca' },
{ label: 'United Kingdom', value: 'uk' }
],
placeholder: 'Select your country'
}
}

Select with dynamic options

const dynamicSelectConfig = {
type: 'select',
data: {
id: 'select',
name: 'dynamicSelect',
label: 'Select Post Title *',
tooltip: 'Select a title from the list of posts.',
fetchUrl: 'https://jsonplaceholder.typicode.com/posts',
transformOptions: (options) => {
return options.map((option: { title: string }) => ({
value: option.title,
label: option.title
}))
},
placeholder: 'Select a title'
}
}