Text input is an interactive component that allows users to enter free-form text responses in modals. It supports both short, single-line inputs and longer, multi-line paragraph inputs.

Text inputs can only be used within modals.

When defining a text input component, you can set attributes to customize the behavior and appearance of it. However, not all attributes will be returned in the text input interaction payload.

interface APITextInputComponent {
    custom_id: string;
    id?: number;
    label?: string;
    max_length?: number;
    min_length?: number;
    placeholder?: string;
    required?: boolean;
    style: TextInputStyle;
    type: TextInput;
    value?: string;
}

Hierarchy (View Summary)

Properties

custom_id: string

The custom id for the text input

id?: number

32 bit integer used as an optional identifier for component

The id field is optional and is used to identify components in the response from an interaction that aren't interactive components. The id must be unique within the message and is generated sequentially if left empty. Generation of ids won't use another id that exists in the message if you have one defined for another component.

label?: string

Text that appears on top of the text input field, max 45 characters.

Cannot be used in a label component.

max_length?: number

Maximal length of text input

min_length?: number

Minimal length of text input

placeholder?: string

Placeholder for the text input

required?: boolean

Whether this text input is required

One of text input styles

type: TextInput

The type of the component

value?: string

The pre-filled text in the text input