Textarea
The Textarea field renders a native multi-line text control.
Basic Usage
use InertiaUI\Forms\Fields\Textarea;
Textarea::make('bio');The frontend renders three rows by default. The serialized rows value stays null, so this fallback may change in the future without changing form payloads.
Rows and Columns
To set the native row and column hints, you may use the rows and cols methods:
Textarea::make('bio')->rows(6);
Textarea::make('code')->cols(80);
Textarea::make('notes')
->rows(8)
->cols(60);Both methods accept null to clear the attribute. The textarea ignores rows while auto-resize is enabled. The cols value stays a native hint, because the package styles keep the control full width.
Auto-Resize
The autoResize method grows the textarea with its content:
Textarea::make('bio')
->autoResize()
->minHeight(100)
->maxHeight(400);Auto-resize measures the content on mount and after every value change. The frontend uses an 80 pixel minimum height unless you call the minHeight method. The maxHeight method caps the growth and lets the textarea scroll. Heights only affect the layout and don't add validation rules.
Character Count
The showCharacterCount method shows the current string length below the textarea:
Textarea::make('bio')
->maxLength(500)
->showCharacterCount();The counter is visual only and is off by default. Pair it with the maxLength method to show current / maximum. The native maxlength attribute guides the browser, while the generated Laravel max rule stays the server-side contract.
Length, Placeholder, and Focus
You may combine length limits, a placeholder, and autofocus on the same textarea:
Textarea::make('description')
->minLength(10)
->maxLength(1000)
->placeholder('Tell us about yourself...')
->autofocus();The minLength and maxLength methods set the native attributes and add the matching Laravel rules. Passing null clears a generated limit and its rule. Calling placeholder(null) clears the placeholder text, and autofocus(false) turns the native autofocus attribute off.
Textarea also supports the shared visibility, authorization, layout, help, label, class, and part-class APIs. See Conditional Visibility, Authorization, Validation, and Styling.
Using the Component Directly
You may render the Textarea component with local state, or pass it serialized field props during manual form rendering:
<script setup lang="ts">
import { ref } from 'vue'
import { Textarea } from '@inertiaui/form-vue/components'
const summary = ref('Outline the launch plan for the customer team.')
const notes = ref('Read-only handoff notes for support.')
const trackBlur = () => {}
</script>
<template>
<div class="grid gap-4">
<Textarea
v-model="summary"
id="launch-summary"
name="summary"
label="Launch summary"
help="Keep the brief under 500 characters."
placeholder="Summarize the plan..."
:min-length="20"
:max-length="500"
required
autofocus
auto-resize
:min-height="120"
:max-height="260"
show-character-count
data-testid="launch-summary"
@blur="trackBlur"
/>
<Textarea
v-model="notes"
name="handoff_notes"
label="Handoff notes"
:rows="6"
:cols="80"
readonly
/>
</div>
</template>import { useState } from 'react'
import { Textarea } from '@inertiaui/form-react/components'
export function LaunchNotes() {
const [summary, setSummary] = useState<string | null>('Outline the launch plan for the customer team.')
const [notes, setNotes] = useState<string | null>('Read-only handoff notes for support.')
const trackBlur = () => {}
return (
<div className="grid gap-4">
<Textarea
value={summary}
onValueChange={setSummary}
id="launch-summary"
name="summary"
label="Launch summary"
help="Keep the brief under 500 characters."
placeholder="Summarize the plan..."
minLength={20}
maxLength={500}
required
autofocus
autoResize
minHeight={120}
maxHeight={260}
showCharacterCount
data-testid="launch-summary"
onBlur={trackBlur}
/>
<Textarea
value={notes}
onValueChange={setNotes}
name="handoff_notes"
label="Handoff notes"
rows={6}
cols={80}
readonly
/>
</div>
)
}Vue uses v-model, while React uses a controlled value with onValueChange. Native attributes and listeners target the underlying <textarea> element. See Native Attributes And Events.