> ## Documentation Index
> Fetch the complete documentation index at: https://filament-34a8cf01.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Textarea

> [!WARNING]
>
> You are currently viewing the documentation for Filament 4.x, which is a previous version of Filament.
>
> Looking for the current stable version? Visit the [5.x documentation](https://filament-34a8cf01.mintlify.site/5.x/forms/textarea.md).

## Introduction

The textarea allows you to interact with a multi-line string:

```php theme={"theme":"gruvbox-dark-hard"}
use Filament\Forms\Components\Textarea;

Textarea::make('description')
```

Loading preview

![Textarea](https://filament-34a8cf01.mintlify.site/docs/images/4.x/light/forms/fields/textarea/simple.jpg)

## Resizing the textarea

You may change the size of the textarea by defining the `rows()` and `cols()` methods:

```php theme={"theme":"gruvbox-dark-hard"}
use Filament\Forms\Components\Textarea;

Textarea::make('description')
    ->rows(10)
    ->cols(20)
```

Loading preview

![Textarea with custom row size](https://filament-34a8cf01.mintlify.site/docs/images/4.x/light/forms/fields/textarea/rows.jpg)

<details>
  <summary />

  [Learn more about utility injection.](https://filament-34a8cf01.mintlify.site/4.x/forms/overview.md#field-utility-injection)
</details>

### Autosizing the textarea

You may allow the textarea to automatically resize to fit its content by setting the `autosize()` method:

```php theme={"theme":"gruvbox-dark-hard"}
use Filament\Forms\Components\Textarea;

Textarea::make('description')
    ->autosize()
```

Optionally, you may pass a boolean value to control if the textarea should be autosizeable or not:

```php theme={"theme":"gruvbox-dark-hard"}
use Filament\Forms\Components\Textarea;

Textarea::make('description')
    ->autosize(FeatureFlag::active())
```

<details>
  <summary />

  [Learn more about utility injection.](https://filament-34a8cf01.mintlify.site/4.x/forms/overview.md#field-utility-injection)
</details>

Loading preview

![Textarea with autosize](https://filament-34a8cf01.mintlify.site/docs/images/4.x/light/forms/fields/textarea/autosize.jpg)

## Making the field read-only

Not to be confused with [disabling the field](https://filament-34a8cf01.mintlify.site/4.x/forms/overview.md#disabling-a-field), you may make the field "read-only" using the `readOnly()` method:

```php theme={"theme":"gruvbox-dark-hard"}
use Filament\Forms\Components\Textarea;

Textarea::make('description')
    ->readOnly()
```

There are a few differences, compared to [`disabled()`](./overview#disabling-a-field):

* When using `readOnly()`, the field will still be sent to the server when the form is submitted. It can be mutated with the browser console, or via JavaScript. You can use [`saved(false)`](./overview#preventing-a-field-from-being-saved) to prevent this.
* There are no styling changes, such as less opacity, when using `readOnly()`.
* The field is still focusable when using `readOnly()`.

Optionally, you may pass a boolean value to control if the field should be read-only or not:

```php theme={"theme":"gruvbox-dark-hard"}
use Filament\Forms\Components\Textarea;

Textarea::make('description')
    ->readOnly(FeatureFlag::active())
```

<details>
  <summary />

  [Learn more about utility injection.](https://filament-34a8cf01.mintlify.site/4.x/forms/overview.md#field-utility-injection)
</details>

## Disabling Grammarly checks

If the user has Grammarly installed and you would like to prevent it from analyzing the contents of the textarea, you can use the `disableGrammarly()` method:

```php theme={"theme":"gruvbox-dark-hard"}
use Filament\Forms\Components\Textarea;

Textarea::make('description')
    ->disableGrammarly()
```

Optionally, you may pass a boolean value to control if the field should disable Grammarly checks or not:

```php theme={"theme":"gruvbox-dark-hard"}
use Filament\Forms\Components\Textarea;

Textarea::make('description')
    ->disableGrammarly(FeatureFlag::active())
```

<details>
  <summary />

  [Learn more about utility injection.](https://filament-34a8cf01.mintlify.site/4.x/forms/overview.md#field-utility-injection)
</details>

## Trimming whitespace

You can automatically trim whitespace from the beginning and end of the textarea value using the `trim()` method:

```php theme={"theme":"gruvbox-dark-hard"}
use Filament\Forms\Components\Textarea;

Textarea::make('description')
    ->trim()
```

You may want to enable trimming globally for all textareas, similar to Laravel's `TrimStrings` middleware. You can do this in a service provider using the `configureUsing()` method:

```php theme={"theme":"gruvbox-dark-hard"}
use Filament\Forms\Components\Textarea;

Textarea::configureUsing(function (Textarea $component): void {
    $component->trim();
});
```

## Textarea validation

As well as all rules listed on the [validation](https://filament-34a8cf01.mintlify.site/4.x/forms/validation.md) page, there are additional rules that are specific to textareas.

### Length validation

You may limit the length of the textarea by setting the `minLength()` and `maxLength()` methods. These methods add both frontend and backend validation:

```php theme={"theme":"gruvbox-dark-hard"}
use Filament\Forms\Components\Textarea;

Textarea::make('description')
    ->minLength(2)
    ->maxLength(1024)
```

You can also specify the exact length of the textarea by setting the `length()`. This method adds both frontend and backend validation:

```php theme={"theme":"gruvbox-dark-hard"}
use Filament\Forms\Components\Textarea;

Textarea::make('question')
    ->length(100)
```

<details>
  <summary />

  [Learn more about utility injection.](https://filament-34a8cf01.mintlify.site/4.x/forms/overview.md#field-utility-injection)
</details>

[Edit this page on GitHub](https://github.com/filamentphp/filament/edit/4.x/packages/forms/docs/15-textarea.md)

## Sponsored by

[Your logo here](https://github.com/sponsors/danharrin)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.