Skip to content
Bladewell

<x-widget.textarea>

Textarea Blade component for Laravel and Livewire

Grows with its content, or resizes by dragging. Optional character counter. Works with Livewire wire:model.

php artisan bladewell:add textarea
Works with
Laravel 12 and 13, Livewire 3 and 4, Tailwind CSS 4.1+, PHP 8.3+
Guide
Build a Laravel form from your validation rules

Usage

Livewire

In a Livewire component, bind with wire:model (deferred) or wire:model.live.debounce for live checks; no name is needed. The text shows the property after every render, the counter and height included, so clearing it in PHP after a save empties the box.

Blade
<form wire:submit="post" class="space-y-5">
    <x-widget.textarea label="Comment" counter maxlength="500" wire:model="comment" />

    <button type="submit">Post</button>
</form>

On the server

The textarea can't stop a request that skips it. Here's what to check on your server.

Security

Examples

Textarea

By default it grows with its content between min-rows and max-rows (5), including when a script sets its value. resizable gives it a drag handle instead: the user sets the height, from min-rows down to max-rows if you set one. Each new height fires a textarea:resize event.

Show code
Blade
<div class="grid gap-6 sm:grid-cols-2">
    <x-widget.textarea name="notes" label="Notes" placeholder="Grows as you type..." />
    <x-widget.textarea name="message" label="Message" placeholder="Drag the corner to resize" resizable :min-rows="4" />
</div>

Counter

counter shows characters used against maxlength. It's opt-in, so a field with maxlength doesn't get one by default.

0 / 160

Show code
Blade
<x-widget.textarea name="bio" label="Bio" maxlength="160" counter placeholder="A line or two about you" />

Props

Other attributes, such as autocomplete or data-*, are passed through to the element. class styles the component's outer wrapper.

<x-widget.textarea>

Prop Default Description
name null What it submits as; its error and old input are found under it. Optional with wire:model, which then names it.
id null Defaults to one made from the name (or the wire:model property).
label null Shown above the field, and its name for screen readers.
value null The value to show. Old input wins after a failed submit; with wire:model and no value, the bound Livewire property.
placeholder null Shown while it's empty.
error null An error message of your own; otherwise the validation error for the name, from the session or Livewire.
info null A hint under the field.
bag 'default' Which error bag to read the error from.
disabled false Greyed out: it can't be changed.
readonly false Shown, and submitted, but it can't be edited.
min-rows 3 The height to start at, in lines.
max-rows null Grows up to this many lines, then scrolls (5 by default; no limit when resizable).
counter false With maxlength: a live count under the field (12 / 40).
resizable false Lets people drag it taller instead of sizing it to the text.

Accessibility

All 2 examples above are checked with axe-core against the WCAG 2.2 A and AA rules, in the light theme and the dark one, both as the page draws and with each popover, dialog, toast and tooltip opened, on every change. A change that fails can't be merged. Where axe can't decide, such as contrast on SVG text, the test measures the colours itself instead of letting it pass.

Automated checks can't judge everything: how it sounds in a screen reader, and how it feels to use from the keyboard, still need a person. Check those on your own pages too.

Source

What bladewell:add textarea writes to your app with the default namespaces. Prefer to copy by hand? Take these files, plus the ones from Field, and the theme and base CSS.

resources/views/components/widget/textarea/index.blade.php Show
index.blade.php
resources/js/widget/textarea/index.js Show
index.js
app/View/Widget/ElementIds.php Show
ElementIds.php
app/View/Widget/FormField.php Show
FormField.php