obsidian/wiki/payloadcms/fields-textarea.md
2026-05-15 15:40:00 +01:00

3.4 KiB

title aliases tags sources created updated
Textarea Field
textarea-field
payload-textarea
payloadcms
fields
textarea
string
admin
raw/fields__textarea.md
2026-05-15 2026-05-15

Identical to wiki/payloadcms/fields-text but renders a larger multiline input in the Admin Panel. Stores a plain string in the database.

Config

{
  name: 'metaDescription',
  type: 'textarea',
  required: true,
}

Config Options

Option Description
name * DB property name
label Admin Panel label (string or i18n object)
unique DB-level unique index
minLength / maxLength Character length validation
validate Custom validation function (runs on client + backend)
index Build DB index for faster queries
saveToJWT Include in user JWT (top-level auth collections only)
hooks Field lifecycle hooks
access Field-level access control
hidden Hide from all APIs and Admin; still saved to DB
defaultValue Default value
localized Enable per-locale content
required Non-empty validation
virtual true = no DB column; or path string for linked relationship
typescriptSchema Override TS type generation with JSON schema
custom Plugin extension point

Admin Options

Option Description
placeholder Placeholder string
autoComplete Browser autocomplete string
rows Visible text rows (default: 2)
rtl Force right-to-left text direction

Inherits all base wiki/payloadcms/fields-overview options (condition, width, description, components, etc.).

Custom Components

Field Server Component

import { TextareaField } from '@payloadcms/ui'
import type { TextareaFieldServerComponent } from 'payload'

export const CustomTextareaFieldServer: TextareaFieldServerComponent = ({
  clientField, path, schemaPath, permissions,
}) => (
  <TextareaField field={clientField} path={path} schemaPath={schemaPath} permissions={permissions} />
)

Field Client Component

'use client'
import { TextareaField } from '@payloadcms/ui'
import type { TextareaFieldClientComponent } from 'payload'

export const CustomTextareaFieldClient: TextareaFieldClientComponent = (props) => (
  <TextareaField {...props} />
)

Label (Server / Client)

Use FieldLabel from @payloadcms/ui with label, path, and required props — same pattern as other fields.

Key Takeaways

  • Identical to Text field — same DB storage (string), same options; only visual difference is the multiline textarea input
  • rows defaults to 2 — set higher for long content like metaDescription, bio, notes
  • minLength/maxLength run on both client and server via the default validator
  • virtual: true disables DB column; virtual: '<path>' links to a Relationship field
  • saveToJWT embeds the value in the auth token — avoid for large text; use for short identifiers only
  • RTL supportadmin.rtl: true forces right-to-left for Arabic/Hebrew content fields

Key Differences vs Text Field

Text Textarea
Input UI Single-line Multiline (rows)
hasMany mode Yes No
Built-in Slug helper Yes (slugField()) No
Otherwise Identical Identical

Sources