Skip to main content

io.group

Combines multiple I/O method calls into a single form.

Individual I/O methods await within your action until user input is provided, such that each I/O method call results in a distinct step within the generated app. io.group allows you to group multiple I/O methods together to request input all at once in a single step.

caution

io.confirm and io.confirmIdentity are not supported within an io.group.

Custom validation can be performed on groups by chaining a .validate() method call to the group. Learn more about validation here.

Usage

const [name, email, age] = await io.group([
io.input.text("Name"),
io.input.email("Email"),
io.input.number("Age"),
]);

// or

const { name, email, age } = await io.group({
name: io.input.text("Name"),
email: io.input.email("Email"),
age: io.input.number("Age"),
});

Props

Receives an array or object of I/O method calls as its first argument.

info

Dynamic arrays are supported, but discouraged as they make the result's types not statically determinable and extracting the results difficult to reason about.

continueButton

objectOptional

Customizes the button that completes the group's step within the action, submitting any info collected via I/O methods.

label

stringOptional

Text for the continue button. Defaults to "Continue".

theme

"default" | "danger"Optional

Visual theme for the continue button.

Returns

Returns an array or object (depending on input) of its constituent I/O methods' return values.

Similarly to Promise.all, if the contents are defined inline or of constant types, the return values will be correctly typed by TypeScript.

Examples

Named values

Rather than relying on the index-based values returned when providing a list of sub-components to io.group, if you provide an object with named keys, Interval will return the results of the form as an object with values assigned to the provided key for each component. While only slightly more complicated to configure, this can be much more robust at access time or when refactoring the contents of the group.

const { name, email, age } = await io.group({
name: io.input.text("Name"),
email: io.input.email("Email"),
age: io.input.number("Age"),
});
Was this section useful?
On this page