Skip to content
Fields

Textarea ​

Erag\InertiaForms\Fields\Textarea renders a multi-line <textarea>, with optional auto-resize and a character counter.

When to use: comments, descriptions, bios, messages.

php
use Erag\InertiaForms\Fields\Textarea;

Textarea::make('bio')
    ->rows(4)
    ->maxLength(500)
    ->showCharacterCount()
    ->help('Shown on your public profile.');

Examples ​

Each example is a live form built from the PHP below it. Fill it in and press submit to see the data your controller would receive.

Basic ​

A required message box, four lines tall.

php
use Erag\InertiaForms\Fields\Textarea;

Textarea::make('message')->rows(4)->required();

Character counter ​

maxLength() stops typing at 280 characters, and showCharacterCount() shows how many are used.

php
use Erag\InertiaForms\Fields\Textarea;

Textarea::make('status')
    ->label('What are you working on?')
    ->rows(3)
    ->maxLength(280)
    ->showCharacterCount();

Advanced: support ticket ​

Both textareas grow with their content through autoResize(). The description needs at least 20 characters; the second box shows how a multi-line placeholder reads.

php
use Erag\InertiaForms\Fields\Textarea;
use Erag\InertiaForms\Fields\TextInput;

[
    TextInput::make('subject')->required()->maxLength(120),
    Textarea::make('description')
        ->required()
        ->rows(3)
        ->autoResize()
        ->minLength(20)
        ->maxLength(2000)
        ->showCharacterCount()
        ->placeholder('What happened, and what did you expect to happen?'),
    Textarea::make('steps')
        ->label('Steps to reproduce')
        ->autoResize()
        ->placeholder("1. Open the dashboard\n2. Click Export")
        ->help('Optional, but it helps us fix it faster.'),
];

Methods ​

All common field methods are available, plus:

rows(int $rows) ​

Visible number of text lines. Default 3.

php
Textarea::make('message')->rows(6);

autoResize(bool $autoResize = true) ​

Grow the textarea to fit its content instead of showing a scrollbar. Manual resizing is turned off.

php
Textarea::make('notes')->autoResize();

minLength(?int $length) / maxLength(?int $length) ​

Minimum and maximum number of characters. Sets the HTML attributes and adds min:/max: rules.

php
Textarea::make('review')->minLength(20)->maxLength(1000);

showCharacterCount(bool $show = true) ​

Show a live counter under the textarea. With maxLength() it reads 42 / 500; without, just 42.

php
Textarea::make('tweet')->maxLength(280)->showCharacterCount();

Validation rules ​

ConfigurationRules
defaultstring
minLength(20)adds min:20
maxLength(500)adds max:500
php
Textarea::make('bio')->maxLength(200);
// ['nullable', 'string', 'max:200']

Value ​

  • Stores a string.
  • Empty value: ''.

Standalone use ​

vue
<Textarea v-model="notes" :field="notesField" id="notes" :disabled="false" />
tsx
<Textarea field={notesField} id="notes" value={notes} disabled={false} onChange={(value) => setNotes(String(value))} />
svelte
<Textarea field={notesField} id="notes" bind:value={notes} disabled={false} />

Import Textarea from your framework package. See Standalone Components.