text & textarea

The simplest controls. Single-line input (`text`) or multi-line (`textarea`). Both store a single string.

Stored value

string

Supports

  • Plain string values, no formatting
  • Validation rules (required, minLength, maxLength, pattern)
  • Placeholder text and inline help

Config options

defaultstring
Initial value if the author hasn't edited the field.
placeholderstring
Greyed-out hint shown when the input is empty.
helpTextstring
One-line description shown below the input.
validation.requiredboolean
Block save until the field is filled in.
validation.minLengthnumber
Minimum character count.
validation.maxLengthnumber
Maximum character count. Shown as "X / Y" counter in the editor.
validation.patternstring (regex)
Regex the value must match. Enforced client- and server-side.

Example

json
{ "id": "ctrl_eyebrow",
  "type": "text",
  "label": "Eyebrow",
  "attributeKey": "eyebrow",
  "default": "",
  "placeholder": "e.g. New in beta",
  "validation": { "maxLength": 60 },
  "parentPanelId": "panel" }

Notes

Consume

export default function MyBlock({ attributes }) {
  const { eyebrow = '' } = attributes;
  return eyebrow ? <span className="eyebrow">{eyebrow}</span> : null;
}