# Textarea

A textarea field, which auto-resizes and has built-in format buttons.

****

- Read more: <https://getkirby.com/docs/guide/blueprints/fields>
- Source: <https://github.com/getkirby/kirby/tree/5.5.3/config/fields/textarea.php>

****

The textarea field creates a textarea for longer texts with automatic resizing and optional format buttons.

<figure class="image"><a data-lightbox href="https://assets.getkirby.com/media/pages/docs/reference/panel/fields/textarea/68cd1dc6ab-1717846665/textarea.png?width=1416&amp;height=438&amp;enlarge=0"><img alt="" class="rounded" height="286" loading="lazy" sizes="auto" src="https://assets.getkirby.com/media/pages/docs/reference/panel/fields/textarea/68cd1dc6ab-1717846665/textarea.png?width=924&amp;height=286&amp;enlarge=0" srcset="https://assets.getkirby.com/media/pages/docs/reference/panel/fields/textarea/68cd1dc6ab-1717846665/textarea.png?width=462&amp;height=143&amp;enlarge=0 462w, https://assets.getkirby.com/media/pages/docs/reference/panel/fields/textarea/68cd1dc6ab-1717846665/textarea.png?width=690&amp;height=213&amp;enlarge=0 690w, https://assets.getkirby.com/media/pages/docs/reference/panel/fields/textarea/68cd1dc6ab-1717846665/textarea.png?width=924&amp;height=286&amp;enlarge=0 924w, https://assets.getkirby.com/media/pages/docs/reference/panel/fields/textarea/68cd1dc6ab-1717846665/textarea.png?width=1380&amp;height=427&amp;enlarge=0 1380w, https://assets.getkirby.com/media/pages/docs/reference/panel/fields/textarea/68cd1dc6ab-1717846665/textarea.png?width=1416&amp;height=438&amp;enlarge=0 1848w" width="924"></a></figure>

## Example

```yaml
fields:
  text:
    label: Text
    type: textarea
```

## Field properties



<div class="table">
	<table class="parameters">
		<thead>
			<tr>
				<th>Name</th>
				<th>Type</th>
				<th>Default</th>

								<th>Description</th>
							</tr>
		</thead>
		<tbody>
						<tr>
				<td>
					autofocus				</td>
				<td><code class="type type-bool">bool</code></td>

				<td data-label="Default:">
															<code>null</code>
									</td>

								<td>Sets the focus on this field when the form loads. Only the first field with this label gets</td>
							</tr>
						<tr>
				<td>
					buttons				</td>
				<td><code class="type type-mixed">mixed</code></td>

				<td data-label="Default:">
															<code>true</code>
									</td>

								<td>Enables/disables the format buttons. Can either be <code class="type type-bool">true</code>/<code class="type type-bool">false</code> or a list of allowed buttons. Available buttons: <code class="type">headlines</code>, <code class="type">italic</code>, <code class="type">bold</code>, <code class="type">link</code>, <code class="type">email</code>, <code class="type">file</code>, <code class="type">code</code>, <code class="type">ul</code>, <code class="type">ol</code> (as well as  for a divider)</td>
							</tr>
						<tr>
				<td>
					counter				</td>
				<td><code class="type type-bool">bool</code></td>

				<td data-label="Default:">
															<code>true</code>
									</td>

								<td>Enables/disables the character counter in the top right corner</td>
							</tr>
						<tr>
				<td>
					default				</td>
				<td><code class="type type-string">string</code></td>

				<td data-label="Default:">
															<code>null</code>
									</td>

								<td>Sets the default text when a new page/file/user is created</td>
							</tr>
						<tr>
				<td>
					disabled				</td>
				<td><code class="type type-bool">bool</code></td>

				<td data-label="Default:">
															<code>null</code>
									</td>

								<td>If <code class="type type-bool">true</code>, the field is no longer editable and will not be saved</td>
							</tr>
						<tr>
				<td>
					files				</td>
				<td><code class="type type-mixed">mixed</code></td>

				<td data-label="Default:">
															<code>[ ]</code>
									</td>

								<td>Sets the options for the files picker</td>
							</tr>
						<tr>
				<td>
					font				</td>
				<td><code class="type type-string">string</code></td>

				<td data-label="Default:">
															<code>null</code>
									</td>

								<td>Sets the font family (sans or monospace)</td>
							</tr>
						<tr>
				<td>
					help				</td>
				<td><code class="type type-mixed">mixed</code></td>

				<td data-label="Default:">
															<code>null</code>
									</td>

								<td>Optional help text below the field</td>
							</tr>
						<tr>
				<td>
					icon				</td>
				<td><code class="type type-string">string</code></td>

				<td data-label="Default:">
															<code>null</code>
									</td>

								<td>Optional icon that will be shown at the end of the field</td>
							</tr>
						<tr>
				<td>
					label				</td>
				<td><code class="type type-mixed">mixed</code></td>

				<td data-label="Default:">
															<code>null</code>
									</td>

								<td>The field label can be set as string or associative array with translations</td>
							</tr>
						<tr>
				<td>
					maxlength				</td>
				<td><code class="type type-int">int</code></td>

				<td data-label="Default:">
															<code>null</code>
									</td>

								<td>Maximum number of allowed characters</td>
							</tr>
						<tr>
				<td>
					minlength				</td>
				<td><code class="type type-int">int</code></td>

				<td data-label="Default:">
															<code>null</code>
									</td>

								<td>Minimum number of required characters</td>
							</tr>
						<tr>
				<td>
					placeholder				</td>
				<td><code class="type type-mixed">mixed</code></td>

				<td data-label="Default:">
															<code>null</code>
									</td>

								<td>Optional placeholder value that will be shown when the field is empty</td>
							</tr>
						<tr>
				<td>
					required				</td>
				<td><code class="type type-bool">bool</code></td>

				<td data-label="Default:">
															<code>null</code>
									</td>

								<td>If <code class="type type-bool">true</code>, the field has to be filled in correctly to be saved.</td>
							</tr>
						<tr>
				<td>
					size				</td>
				<td><code class="type type-string">string</code></td>

				<td data-label="Default:">
															<code>null</code>
									</td>

								<td>Changes the size of the textarea. Available sizes: <code class="type">small</code>, <code class="type">medium</code>, <code class="type">large</code>, <code class="type">huge</code></td>
							</tr>
						<tr>
				<td>
					spellcheck				</td>
				<td><code class="type type-bool">bool</code></td>

				<td data-label="Default:">
															<code>true</code>
									</td>

								<td>If <code class="type type-bool">false</code>, spellcheck will be switched off</td>
							</tr>
						<tr>
				<td>
					translate				</td>
				<td><code class="type type-bool">bool</code></td>

				<td data-label="Default:">
															<code>true</code>
									</td>

								<td>If <code class="type type-bool">false</code>, the field will be disabled in non-default languages and cannot be translated. This is only relevant in multi-language setups.</td>
							</tr>
						<tr>
				<td>
					uploads				</td>
				<td><code class="type type-mixed">mixed</code></td>

				<td data-label="Default:">
															<code>[ ]</code>
									</td>

								<td>Sets the upload options for linked files (since 3.2.0)</td>
							</tr>
						<tr>
				<td>
					when				</td>
				<td><code class="type type-mixed">mixed</code></td>

				<td data-label="Default:">
															<code>null</code>
									</td>

								<td>Conditions when the field will be shown (since 3.1.0)</td>
							</tr>
						<tr>
				<td>
					width				</td>
				<td><code class="type type-string">string</code></td>

				<td data-label="Default:">
															<code>'1/1'</code>
									</td>

								<td>The width of the field in the field grid, e.g. <code class="type">1/1</code>, <code class="type">1/2</code>, <code class="type">1/3</code>, <code class="type">1/4</code>, <code class="type">2/3</code>, <code class="type">3/4</code></td>
							</tr>
					</tbody>
	</table>
</div>

## Sizes

In some section layouts, a small textarea looks lost. The `size` option sets an initial default height for empty textareas before auto-sizing kicks in. Available sizes:

- `small`
- `medium`
- `large`
- `huge`

```yaml
fields:
  text:
    label: Text
    type: textarea
    size: large
```

## Toolbar

### Disabling the toolbar

If the formatting toolbar should not be available, you can switch it off entirely:

```yaml
fields:
  text:
    label: Text
    type: textarea
    buttons: false
```

### Customizing the toolbar

You can also specify which buttons to show in the toolbar.

```yaml
fields:
  text:
    label: Text
    type: textarea
    buttons:
      - bold
      - '|'
      - link
      - email
```

You can add your <a href="https://getkirby.com/docs/reference/plugins/extensions/textarea-buttons">custom textarea buttons</a> in a plugin.

## File upload and select

<figure class="image"><a data-lightbox href="https://assets.getkirby.com/media/pages/docs/reference/panel/fields/textarea/e3aa889078-1717846665/file-selector.png?width=1508&amp;height=552&amp;enlarge=0"><img alt="" class="rounded" height="338" loading="lazy" sizes="auto" src="https://assets.getkirby.com/media/pages/docs/reference/panel/fields/textarea/e3aa889078-1717846665/file-selector.png?width=924&amp;height=338&amp;enlarge=0" srcset="https://assets.getkirby.com/media/pages/docs/reference/panel/fields/textarea/e3aa889078-1717846665/file-selector.png?width=462&amp;height=169&amp;enlarge=0 462w, https://assets.getkirby.com/media/pages/docs/reference/panel/fields/textarea/e3aa889078-1717846665/file-selector.png?width=690&amp;height=253&amp;enlarge=0 690w, https://assets.getkirby.com/media/pages/docs/reference/panel/fields/textarea/e3aa889078-1717846665/file-selector.png?width=924&amp;height=338&amp;enlarge=0 924w, https://assets.getkirby.com/media/pages/docs/reference/panel/fields/textarea/e3aa889078-1717846665/file-selector.png?width=1380&amp;height=505&amp;enlarge=0 1380w, https://assets.getkirby.com/media/pages/docs/reference/panel/fields/textarea/e3aa889078-1717846665/file-selector.png?width=1508&amp;height=552&amp;enlarge=0 1848w" width="924"></a></figure>

The file upload and select button is super useful if you want to embed images or other files right in your text.

You can define the button behavior with the `files` and `uploads` options:

```yaml
textarea:
  type: textarea
  files: page.images
  uploads: textarea-upload
```

By default all files will be uploaded to the current page and without a predefined template. With the additional options you can fetch files from anywhere and upload them to specific pages. You can also control which file template should be assigned by default:

```yaml
textarea:
  type: textarea
  files:
    query: site.find("media").files.template("textarea-upload")
    image:
      cover: true
  uploads:
    parent: site.find("media")
    template: textarea-upload
```

You can also deactivate file uploads:

```yaml
textarea:
  type: textarea
  uploads: false
```

<h2 id="length-restrictions"><a href="#length-restrictions" tabindex="-1">Length restrictions</a></h2>
<p>You can control the maximal and/or minimal length of the entered text by using the <code class="type">maxlength</code> and/or <code class="type">minlength</code> option. A handy indicator of the current text length will be displayed in the upper right corner.</p>
<figure class="code">
<pre><code class="language-yaml">fields:
  name:
    label: Name
    type: textarea
    minlength: 10
    maxlength: 1000</code></pre>
</figure>

## Monospace

You can set the `font` option to `monospace`, for example for fields that contain code:

```yaml
fields:
  text:
    label: Text
    type: textarea
    font: monospace
```

## How to use in templates/snippets

The usual way to render the value of a textarea field is using the `kirbytext()` method (or the shortcut `kt()`).

```php
<?= $page->text()->kirbytext() ?>
<?= $page->text()->kt() ?>
```

However, there might be situations, where you want to parse KirbyTags, but not render block level elements:

```php
<p><?= $page->text()->kt()->inline() ?></p>
```

For more field manipulations, check out Kirby's <a href="https://getkirby.com/docs/reference/templates/field-methods">field methods</a>.