Typst field types
Annotations
Write an annotation as a comment after the field, inside the #let data = (...) block: // @type: date @format: DD MMM YYYY.
| Annotation | Box shown on the Generate page and in forms | Value the template receives |
|---|---|---|
@type: text | One line of text | The text |
@type: textarea | Several lines of text | The text |
@type: number | A number | Text; use int() or float() to calculate |
@type: date @format: … | A date picker | The date written in the @format pattern |
@type: boolean | A checkbox | "true" or "false" |
@type: image | An upload, or a link to an image | The uploaded file's name or the link |
@type: color | A colour picker | A hex value, such as "#1a56db"; use rgb() |
@type: url | One line of text | The link |
@type: array @columns: … | A table where rows can be added and removed | A list of rows to loop over |
@type: json | A box for JSON text | Text; read it with json(bytes(...)). Older templates only |
@label: … | Sets the label shown above the box |
@type: date without @format is a plain text box.
A field with no annotation gets a type from its name: a name ending in _date is a date, qty, amount or total is a number, logo or photo is an image, color is a colour, url or link is a link, notes or description is several lines of text, and names starting with is_ or has_ are checkboxes.
Date format tokens
| Token | Prints |
|---|---|
DD | Day with a leading zero (01 to 31) |
D | Day without a leading zero (1 to 31) |
MMMM | Full month name (January) |
MMM | Short month name (Jan) |
MM | Month number with a leading zero (01 to 12) |
M | Month number without a leading zero (1 to 12) |
YYYY | Four-digit year (2026) |
YY | Two-digit year (26) |
List columns
@columns lists each column of an array field as name:type, separated by commas: @columns: desc:text,qty:number,amount:number.
Column types: text, number, date, boolean, image, color, url. A date column can carry its format: delivery_date:date:DD MMM YYYY.
Where values come from
| Way of generating | Values come from |
|---|---|
| Generate page | The boxes on the page |
| Bulk generation | One row of the CSV file per document; column headers match field names |
| Forms | Each response, through the form's field mapping |
| API | The data object in the request |
| Dynamic URLs | The values in the link |
Every value arrives as text, except array fields, which arrive as a list. A field that is not sent prints blank; see Blank values.
Last updated on