select
The select
property is used to define a selectable list of values and/or options. This is functionally similar to the options property but is displayed as a select in the admin, allowing for more options without overwhelming the user and allowing the user to search options.
Options can be defined as strings, numbers, or objects with a label
and value
property.
import { atom, select } from '@iridiumcms/core';
export const sample = atom('sample', {
myList: select([
1,
'option1',
{ label: 'Option 2', value: 'option2' },
]),
});
Configuration
The options
field takes an optional configuration object with the following properties:
- valuesThe step size of the slider. Defaults to
(string | number | OptionValue)[]
undefined
. - defaultValuesThe default value of the field. Defaults to
(string | number | OptionValue)[]
undefined
. - displayNameThe display name of the field. Defaults to the name of the property.
string
- requiredWhether the field is required. Defaults to
boolean
false
. - layoutThe layout of the field in the admin. Defaults to
LAYOUT
LAYOUT.full
.
OptionValue
An OptionValue
is an object with a label
and value
property.
atom('sample', {
myOptions: select([
{
label: 'Option 1',
value: 'option1',
},
{
label: 'Option 2',
value: 'option2',
},
]),
});
- labelThe option label.
string
- valueThe option value.
string | number