Toolforge Docs
DocsIO PrimitivesnumberInput

numberInput

Prompts the user for a numeric input with optional min/max constraints.

Usage

Number input

const age = await io.numberInput({
  label: 'Age',
  min: 0,
  max: 120,
})

Props

PropDescriptionTypeRequiredDefault
labelThe label for the number inputstringYes
descriptionThe description for the number inputstringNoundefined
optionalWhether the number input is optionalbooleanNofalse
minThe minimum number allowednumberNoundefined
maxThe maximum number allowednumberNoundefined
maxRetryAttemptsMaximum retry attempts for invalid inputnumberNo5
validationSchemaCustom validation schemaz.ZodNumber | z.ZodOptional<z.ZodNumber>Noundefined
defaultValueThe default value for the number inputnumberNoundefined

Returns

Returns a Promise<number> or Promise<number | undefined> if optional: true.

Examples

Percentage input

Percentage input

const discount = await io.numberInput({
  label: 'Discount Percentage',
  min: 0,
  max: 100,
  description: 'Enter a value between 0 and 100',
  defaultValue: 0,
})

Optional number

Optional number

const quantity = await io.numberInput({
  label: 'Quantity (optional)',
  optional: true,
  min: 1,
})

On this page