textAreaField
A multi-line plain-text input. Descriptions, excerpts, addresses, notes.
import { textAreaField } from 'nextjs-cms/core/fields'Basic usage
textAreaField({ name: 'description' })With every option
textAreaField({
name: 'excerpt',
label: { en: 'Excerpt', ar: 'مقتطف' },
required: true,
order: 3,
localized: true,
conditionalRules: [{ field: showExcerpt, condition: 'equals', value: true }],
placeholder: 'One or two sentences shown on listing pages',
minLength: 50,
maxLength: 300,
sanitize: true,
rtl: false,
})Options
| Option | Type | Default | Description |
|---|---|---|---|
placeholder | string | none | Hint shown in the empty textarea. |
minLength | number | none | Minimum number of characters. |
maxLength | number | none | Maximum number of characters. Unlike textField, it does not change the column (always LONGTEXT). |
sanitize | boolean | false | HTML-escape the value before saving. See textField sanitize. |
rtl | boolean | locale-based | Force the text direction. See textField rtl. |
defaultValue | string | none | Pre-filled value. |
Plus the common options.
Options in detail
maxLength for SEO fields
Search engines truncate meta descriptions around 155–160 characters. Enforce it:
textAreaField({ name: 'meta_description', label: 'Meta description', maxLength: 160 })Line breaks
The value is stored exactly as typed, including newlines (\n). To display paragraphs on your website:
export function Multiline({ text }: { text: string }) {
return <p className='whitespace-pre-line'>{text}</p>
}Need bold, links, or lists? Use richTextField instead.
Storage
| Column | LONGTEXT CHARACTER SET utf8mb4 |
| Value | Plain text with \n line breaks |