# Writer

A simple WYSIWYG editor field for inline content with formats like bold, italic, etc.

****

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

****

<figure class="image"><a data-lightbox href="https://assets.getkirby.com/media/pages/docs/reference/panel/fields/writer/69d5fd821a-1717846665/writer.png?width=1416&amp;height=580&amp;enlarge=0"><img alt="" class="rounded" height="378" loading="lazy" sizes="auto" src="https://assets.getkirby.com/media/pages/docs/reference/panel/fields/writer/69d5fd821a-1717846665/writer.png?width=924&amp;height=378&amp;enlarge=0" srcset="https://assets.getkirby.com/media/pages/docs/reference/panel/fields/writer/69d5fd821a-1717846665/writer.png?width=462&amp;height=189&amp;enlarge=0 462w, https://assets.getkirby.com/media/pages/docs/reference/panel/fields/writer/69d5fd821a-1717846665/writer.png?width=690&amp;height=283&amp;enlarge=0 690w, https://assets.getkirby.com/media/pages/docs/reference/panel/fields/writer/69d5fd821a-1717846665/writer.png?width=924&amp;height=378&amp;enlarge=0 924w, https://assets.getkirby.com/media/pages/docs/reference/panel/fields/writer/69d5fd821a-1717846665/writer.png?width=1380&amp;height=565&amp;enlarge=0 1380w, https://assets.getkirby.com/media/pages/docs/reference/panel/fields/writer/69d5fd821a-1717846665/writer.png?width=1416&amp;height=580&amp;enlarge=0 1848w" width="924"></a></figure>

#### Example

```yaml
fields:
  text:
    label: Writer
    type: writer
```

## 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>
					after				</td>
				<td><code class="type type-mixed">mixed</code></td>

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

								<td>Optional text that will be shown after the input</td>
							</tr>
						<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>
					before				</td>
				<td><code class="type type-mixed">mixed</code></td>

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

								<td>Optional text that will be shown before the input</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-mixed">mixed</code></td>

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

								<td>Default value for the field, which will be used when a 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>
					headings				</td>
				<td><code class="type type-array">array</code></td>

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

								<td>Available heading levels</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>
					inline				</td>
				<td><code class="type type-bool">bool</code></td>

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

								<td>Enables inline mode, which will not wrap new lines in paragraphs and creates hard breaks instead.</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>
					marks				</td>
				<td><code class="type type-array">array</code><span class="px-1 color-gray-400" aria-hidden="true">|</span><span class="sr-only">or</span><code class="type type-bool">bool</code></td>

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

								<td>Sets the allowed HTML formats. Available formats: <code class="type">bold</code>, <code class="type">italic</code>, <code class="type">underline</code>, <code class="type">strike</code>, <code class="type">code</code>, <code class="type">link</code>, <code class="type">email</code>. Activate/deactivate them all by passing <code class="type type-bool">true</code>/<code class="type type-bool">false</code>. Default marks are <code class="type">bold</code>, <code class="type">italic</code>, <code class="type">underline</code>, <code class="type">strike</code>, <code class="type">link</code>, <code class="type">email</code></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>
					nodes				</td>
				<td><code class="type type-array">array</code><span class="px-1 color-gray-400" aria-hidden="true">|</span><span class="sr-only">or</span><code class="type type-bool">bool</code></td>

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

								<td>Sets the allowed nodes. Available nodes: <code class="type">paragraph</code>, <code class="type">heading</code>, <code class="type">bulletList</code>, <code class="type">orderedList</code>, <code class="type">quote</code>. Activate/deactivate them all by passing <code class="type type-bool">true</code>/<code class="type type-bool">false</code>. Default nodes are <code class="type">paragraph</code>, <code class="type">heading</code>, <code class="type">bulletList</code>, <code class="type">orderedList</code>.</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>
					toolbar				</td>
				<td><code class="type type-mixed">mixed</code></td>

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

								<td>Toolbar options, incl. <code class="type">marks</code> (to narrow down which marks should have toolbar buttons), <code class="type">nodes</code> (to narrow down which nodes should have toolbar dropdown entries) and <code class="type">inline</code> to set the position of the toolbar (false = sticking on top of the field)</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>
					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>

## Marks

The writer field supports the following marks by default:

- `bold`
- `italic`
- `underline`
- `strike`
- `code`
- `link`
- `email`
- `sub`
- `sup`
- `clear`

The special mark `|` can be used to separate marks in the toolbar by a vertical line.

```yaml
fields:
  text:
    type: writer
    inline: true
    marks:
      - bold
      - italic
      - '|'
      - strike
```

<figure class="image"><a data-lightbox href="https://assets.getkirby.com/media/pages/docs/reference/panel/fields/writer/69d5fd821a-1717846665/writer.png?width=1416&amp;height=580&amp;enlarge=0"><img alt="" class="rounded" height="378" loading="lazy" sizes="auto" src="https://assets.getkirby.com/media/pages/docs/reference/panel/fields/writer/69d5fd821a-1717846665/writer.png?width=924&amp;height=378&amp;enlarge=0" srcset="https://assets.getkirby.com/media/pages/docs/reference/panel/fields/writer/69d5fd821a-1717846665/writer.png?width=462&amp;height=189&amp;enlarge=0 462w, https://assets.getkirby.com/media/pages/docs/reference/panel/fields/writer/69d5fd821a-1717846665/writer.png?width=690&amp;height=283&amp;enlarge=0 690w, https://assets.getkirby.com/media/pages/docs/reference/panel/fields/writer/69d5fd821a-1717846665/writer.png?width=924&amp;height=378&amp;enlarge=0 924w, https://assets.getkirby.com/media/pages/docs/reference/panel/fields/writer/69d5fd821a-1717846665/writer.png?width=1380&amp;height=565&amp;enlarge=0 1380w, https://assets.getkirby.com/media/pages/docs/reference/panel/fields/writer/69d5fd821a-1717846665/writer.png?width=1416&amp;height=580&amp;enlarge=0 1848w" width="924"></a></figure>

<info>
You can extend Kirby to <a href="https://getkirby.com/docs/reference/plugins/extensions/writer-marks-nodes">include custom marks</a>.
</info>

## Nodes

Apart from paragraph nodes, the writer field supports lists, headings, horizontal rules and quotes. You can fine-tune the writer field from your blueprint by defining the available block formats (nodes).

The writer field supports the following nodes by default:

- `paragraph`
- `bulletList`
- `orderedList`
- `heading`
- `horizontalRule`
- `quote`

Unsupported formats will automatically be ignored when content is pasted and the toolbar will also not include the matching buttons.

```yaml
fields:
  writer:
    type: writer
    nodes:
      - heading
      - bulletList
      - orderedList
```

<figure class="image"><a data-lightbox href="https://assets.getkirby.com/media/pages/docs/reference/panel/fields/writer/a43872b874-1717846665/writer-extended.png?width=986&amp;height=471&amp;enlarge=0"><img alt="" class="rounded" height="441" loading="lazy" sizes="auto" src="https://assets.getkirby.com/media/pages/docs/reference/panel/fields/writer/a43872b874-1717846665/writer-extended.png?width=924&amp;height=441&amp;enlarge=0" srcset="https://assets.getkirby.com/media/pages/docs/reference/panel/fields/writer/a43872b874-1717846665/writer-extended.png?width=462&amp;height=221&amp;enlarge=0 462w, https://assets.getkirby.com/media/pages/docs/reference/panel/fields/writer/a43872b874-1717846665/writer-extended.png?width=690&amp;height=330&amp;enlarge=0 690w, https://assets.getkirby.com/media/pages/docs/reference/panel/fields/writer/a43872b874-1717846665/writer-extended.png?width=924&amp;height=441&amp;enlarge=0 924w, https://assets.getkirby.com/media/pages/docs/reference/panel/fields/writer/a43872b874-1717846665/writer-extended.png?width=986&amp;height=471&amp;enlarge=0 1380w, https://assets.getkirby.com/media/pages/docs/reference/panel/fields/writer/a43872b874-1717846665/writer-extended.png?width=986&amp;height=471&amp;enlarge=0 1848w" width="924"></a></figure>

<info>
You can extend Kirby to <a href="https://getkirby.com/docs/reference/plugins/extensions/writer-marks-nodes">include custom nodes</a>.
</info>

## Toolbar

The `toolbar` option allows you to customize the writer's toolbar:

```yaml
text:
  type: writer
  marks:
    - bold
    - italic
    - link
    - code
  toolbar:
    inline: false
    marks:
      - bold
      - "|"
      - link
```

- `inline` attaches the toolbar to the top of the field (instead of the floating pill style)
- `marks` and `nodes` control which marks and nodes are shown in the toolbar. Make sure that the ones you want to include are actually active and not excluded in the top-level `marks` and `nodes` options (see above). The top-level options define which ones are supported, the toolbar-level options what is shown as buttons in the toolbar. For example, you might want to support the code mark for pasting, but hide it from the toolbar.

## Inline mode

By default, the writer field will supports multiple paragraphs (`<p>`). In inline mode, hitting enter will create breaks instead of creating a new paragraph.

```yaml
fields:
  text:
    type: writer
    inline: true
```

In `inline` mode, all nodes (see above) are disabled.

## Heading levels

You can set the available heading levels in the writer field with the `headings` option:

```yaml
fields:
  text:
    type: writer
    headings:
      - 2
      - 3
      - 4
```

## How to use in templates/snippets

The content of the writer field is stored as plain HTML. To render the field in your template, echo the value.

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