io.input.textarea

Longer text, over as many lines as it takes.

io.input.textarea asks a person for text that can span several lines. Use it for a reason, a note or a message. The handler gets a string with the line breaks the person typed. The server checks every answer before your code goes on.

The simplest one

The whole action file, and roughly what your team sees when it runs.

src/actions/payments/refundPaymentAction.ts
import { app } from '../../app';
export const refundPaymentAction = app.defineAction({
name: 'Refund payment',
handler: async ({ io }) => {
const reason = await io.input.textarea(
'Why refund this payment?',
{ helpText: 'Goes to the customer with the refund' },
);
return `Refund noted: ${reason}`;
},
});
The code. One call in an action, the whole file.
tools.example.com/actions/payments/refund_payment

Refund payment

Why refund this payment?The parcel never arrived.The carrier lost it on the way to Lisbon.Goes to the customer with the refund
Continue
In the browser. Roughly what your team sees. Your theme decides the details.

What you can set

The settings you will reach for most, each with the line of code that turns it on.

lines: 8

As tall as you need. lines sets the visible height, four unless you say otherwise. The person can still drag the field bigger.

const note = await io.input.textarea('Note')

Line breaks kept. The handler gets a string with the line breaks the person typed, as \n.

minLength: 10, maxLength: 500

Length limits. Set the fewest and the most characters. A wrong length comes back with a message under the field.

reason.trim().split(/\s+/).length >= 3

Your own check. .validate() runs on the server after the built-in checks. Return a message and the person writes again.

io.input.textarea('Note').optional()

Or optional. .optional() lets the field stay empty. The handler then gets string | undefined.

note: io.input.textarea('Note'),

Next to other fields. Inside io.group it is one field of a form. One Continue sends them all.

Write your first tool today.

An async function, a few await calls, and the form is in the browser.

AwaitIO is free for small teams, made possible by companies and people who sponsor it.