Toolforge Docs
DocsIO PrimitivesdateInput

dateInput

Prompts the user for a date input. Supports single date, multiple dates, or date ranges.

Usage

date

const birthDate = await io.dateInput({
  label: 'Date of Birth',
  mode: 'single',
  max: new Date().toISOString(),
})

Props

PropDescriptionTypeRequiredDefault
labelThe label for the date inputstringYes
descriptionThe description for the date inputstringNoundefined
optionalWhether the date input is optionalbooleanNofalse
minThe minimum date allowed (ISO format)stringNoundefined
maxThe maximum date allowed (ISO format)stringNoundefined
modeThe mode of the date input'single' | 'multiple' | 'range'No'single'
maxRetryAttemptsMaximum retry attempts for invalid inputnumberNo5
validationSchemaCustom validation schemaz.ZodTypeNoundefined
defaultValueThe default value for the date inputDateFieldOutput<{ mode: M }>Noundefined

Returns

Returns a Promise<string> for mode: 'single', Promise<string[]> for mode: 'multiple', or Promise<{ from: string; to: string }> for mode: 'range'. Return type includes | undefined if optional: true.

Examples

Date range

date-range

const vacationPeriod = await io.dateInput({
  label: 'Vacation Period',
  mode: 'range',
  min: new Date().toISOString(),
})

// Returns: { from: string, to: string }

Multiple dates

multiple-dates

const eventDates = await io.dateInput({
  label: 'Select Event Dates',
  mode: 'multiple',
})

// Returns: string[] (array of ISO datetimes)

On this page