options
The options
property is used to define a selectable list of values and/or options.
Options can be defined as strings, numbers, or objects with a label
and value
property.
import { atom, options } from '@iridiumcms/core';
export const sample = atom('sample', {
myList: options([
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
. - multipleAllow multiple options to be selected, changing the effective behavior from checkboxes to radio buttons. Defaults to
boolean
false
. - defaultValueThe 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: options([
{
label: 'Option 1',
value: 'option1',
},
{
label: 'Option 2',
value: 'option2',
},
]),
});
- labelThe option label.
string
- valueThe option value.
string | number