io.input.text

One line of text, typed by a person.

io.input.text asks a person for one line of text and waits for the answer. The handler gets a string. Use it for a name, a code or a search term. 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/accounts/createAccountAction.ts
import { app } from '../../app';
export const createAccountAction = app.defineAction({
name: 'Create account',
handler: async ({ io }) => {
const company = await io.input.text('Company name', {
placeholder: 'Acme Inc.',
});
return `${company} has an account.`;
},
});
The code. One call in an action, the whole file.
tools.example.com/actions/accounts/create_account

Create account

Company nameAcme Inc.
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.

helpText: 'A user or what they did'

A hint inside and under. placeholder shows in the empty field. helpText sits under it.

defaultValue: account.name

Starts filled. defaultValue opens the field with a value the person can change. Without it, the field starts empty.

minLength: 3, maxLength: 40

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

await io.input.text('Company name')

Required by default. An empty field or one with only spaces is sent back. The server checks it, so the browser cannot skip it.

await io.input.text('Nickname').optional()

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

.validate(checkUsername)

Your own check. .validate() runs on the server after the built-in checks. It can ask your database and return a message for the field.

defaultValue: plan, disabled: true

Shown, not changed. A disabled field shows its starting value and cannot be edited. The handler gets that value whatever the browser sends.

const name = await io.input.text('Name')

A plain string. The handler gets a string, exactly as typed. Spaces around it stay.

company: io.input.text('Company name'),

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.