Components

Radio

Usage

const updatedSubscriptionPlan = await io.input.radio('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.

radiorequired
labelrequired
string

The label to render alongside the radio.

valuerequired
JsonValue

The value to return when checked.

help
string

The help to render below the radio label. Default undefined.

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 radio item.

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.