Components

Checkboxes

Usage

const featuresToEnable = await io.input.checkboxes('Pick features to enable', [
  {
    value: 'feature-analytics',
    label: 'Enhanced Analytics',
    help: 'Provides advanced data insights and reporting capabilities.',
  },
  {
    value: 'feature-chat',
    label: 'Chat Support (beta)',
    help: 'Enables real-time chat support for customers.',
  },
  {
    value: 'feature-darkmode',
    label: 'Dark Mode',
    help: 'Allows users to switch to a dark theme.',
    disabled: true,
  },
  {
    value: 'feature-audit-log',
    label: 'Detailed Audit Log',
    help: 'Tracks all user actions for compliance and accountability.',
  }
])
console.log(featuresToEnable) // ['feature-audit-log', 'feature-chat']

Parameters

labelrequired
string

The label to render above the input.

checkboxesrequired
labelrequired
string

The label to render alongside the checkbox.

valuerequired
JsonValue

The value to return when checked.

disabled
boolean

Disables user input. Default false.

help
string

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

options { ... }
disabled
boolean

Disables user input. Default false.

defaultValue
Array<JsonValue>

Checked by default. Default [].

help
string

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

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.