Components

Select

Usage

const updatedSubscriptionPlan = await io.input.select('Pick a new plan', [
  {
    value: 'iron',
    label: 'Iron Plan',
  },
  {
    value: 'gold',
    label: 'Gold Plan',
    disabled: true, // sold out
  },
  {
    value: 'diamond',
    label: 'Diamond Plan',
  },
  {
    value: 'netherite',
    label: 'Netherite Plan',
  }
])
console.log(updatedSubscriptionPlan) // 'diamond'

Parameters

labelrequired
string

The label to render above the input.

select optionsrequired
labelrequired
string

The label to render alongside the checkbox.

valuerequired
JsonValue

The value to return when checked.

disabled
boolean

Disables user input. Default false.

options { ... }
disabled
boolean

Disables user input. Default false.

help
string

The small help text to render below the label. Default undefined.

defaultValue
JsonValue

The default selected option.

customValidator
(input: unknown) => Promise<string | true>

An asynchronous function that takes unknown input and outputs either true or an error message string to show the user.