Iridium CMSIridium CMS

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:

  • values(string | number | OptionValue)[]
    The step size of the slider. Defaults to undefined.
  • multipleboolean
    Allow multiple options to be selected, changing the effective behavior from checkboxes to radio buttons. Defaults to false.
  • defaultValuestring | number | OptionValue
    The default value of the field. Defaults to undefined.
  • displayNamestring
    The display name of the field. Defaults to the name of the property.
  • requiredboolean
    Whether the field is required. Defaults to false.
  • layoutLAYOUT
    The layout of the field in the admin. Defaults to 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',
    },
  ]),
});
  • labelstring
    The option label.
  • valuestring | number
    The option value.