OPF
SpecDefinition referenceView source

Text Variable

Text content. Plain string or rich TextRun[]. Insert it inline as '{{<id>}}' inside any string (rich text is flattened to plain text there), or reference it whole as 'var:<id>' in a field that accepts string or TextRun[] (the rich runs are kept).

Metadata

Definition
#/$defs/TextVariable
Form
object
Source
spec/schemas/opf.schema.json

Field index

FieldTypeReq.Description
typeconstyesVariable kind. One of color, text, number, date, image, url or list.
type · Allowed values
"text"
valuestring | array<ref:TextRun>—Text this variable resolves to: a plain string, or TextRun[] for rich text.
requiredboolean—Whether the variable must be filled. Defaults to true: a variable with no 'value' is unfilled, and an unfilled required variable is an error in a normal deck and expected in a template. Set false for an optional slot: an unfilled optional variable resolves to empty text (inline tokens) or the field that references it is omitted.
labelstring—Optional short human label for forms and fill panels.
descriptionstring—Optional prose describing what the variable is for, surfaced by pickers, fill forms and agents.
examplestring | array<ref:TextRun>—Illustrative text shown in fill forms and used when a template is previewed with examples. Never written to output.

type

typeconstrequiredyesdefault—

Variable kind. One of color, text, number, date, image, url or list.

type · Allowed values
"text"
Field fragment · type.json
{
  "type": "text"
}

value

typestring | array<ref:TextRun>requirednodefault—

Text this variable resolves to: a plain string, or TextRun[] for rich text.

required

typebooleanrequirednodefaulttrue

Whether the variable must be filled. Defaults to true: a variable with no 'value' is unfilled, and an unfilled required variable is an error in a normal deck and expected in a template. Set false for an optional slot: an unfilled optional variable resolves to empty text (inline tokens) or the field that references it is omitted.

label

typestringrequirednodefault—

Optional short human label for forms and fill panels.

description

typestringrequirednodefault—

Optional prose describing what the variable is for, surfaced by pickers, fill forms and agents.

example

typestring | array<ref:TextRun>requirednodefault—

Illustrative text shown in fill forms and used when a template is previewed with examples. Never written to output.

Complete definition constraints
Exact schema constraints
{
  "type": "object",
  "required": [
    "type"
  ],
  "additionalProperties": false,
  "properties": {
    "type": {
      "type": "string",
      "const": "text",
      "description": "Variable kind. One of color, text, number, date, image, url or list."
    },
    "value": {
      "oneOf": [
        {
          "type": "string"
        },
        {
          "type": "array",
          "items": {
            "$ref": "#/$defs/TextRun"
          }
        }
      ],
      "description": "Text this variable resolves to: a plain string, or TextRun[] for rich text."
    },
    "required": {
      "type": "boolean",
      "default": true,
      "description": "Whether the variable must be filled. Defaults to true: a variable with no 'value' is unfilled, and an unfilled required variable is an error in a normal deck and expected in a template. Set false for an optional slot: an unfilled optional variable resolves to empty text (inline tokens) or the field that references it is omitted."
    },
    "label": {
      "type": "string",
      "description": "Optional short human label for forms and fill panels."
    },
    "description": {
      "type": "string",
      "description": "Optional prose describing what the variable is for, surfaced by pickers, fill forms and agents."
    },
    "example": {
      "oneOf": [
        {
          "type": "string"
        },
        {
          "type": "array",
          "items": {
            "$ref": "#/$defs/TextRun"
          }
        }
      ],
      "description": "Illustrative text shown in fill forms and used when a template is previewed with examples. Never written to output."
    }
  },
  "description": "Text content. Plain string or rich TextRun[]. Insert it inline as '{{<id>}}' inside any string (rich text is flattened to plain text there), or reference it whole as 'var:<id>' in a field that accepts string or TextRun[] (the rich runs are kept)."
}