Iridium CMSIridium CMS

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:

  • values(string | number | OptionValue)[]
    The step size of the slider. Defaults to undefined.
  • defaultValues(string | 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: select([
    {
      label: 'Option 1',
      value: 'option1',
    },
    {
      label: 'Option 2',
      value: 'option2',
    },
  ]),
});
  • labelstring
    The option label.
  • valuestring | number
    The option value.