Input.text

Text input

A text input field

ctx.ui.inputs.text("name", config);

Config

name*
string

The name of the input. This will be the key in the result object.


label
string

The label of the input. If this is not provided, the name will be used as the label.


helpText
string

The help text of the input.


optional
boolean

Whether the input is optional. Inputs are required by default.


disabled
boolean

Whether the input is disabled.


defaultValue
string

The default value of the input.


placeholder
string

The placeholder text of the input.


multiline
boolean

Whether the input is a multiline text input. Default is false and will render a single line text input.


maxLength
number

The maximum length of the input.


minLength
number

The minimum length of the input.

Usage

Elements are rendered by by adding to a page. A page that contains input elements, will return an object with the keys matching the name property of each input.

const result = await ctx.ui.page({
  title: "Text inputs",
  content: [
    ctx.ui.inputs.text("name");
    ctx.ui.inputs.text("email", {
      label: "Email address",
      placeholder: "Enter your email address",
    }),
  ],
});
 
console.log(result.name);
console.log(result.email);