Skip to content
Strife Docs

Reference Field Reference

fields.html()

Rich-text (HTML) editor with configurable formatting and content, callout types, table options and custom components.

Rich-text input. Maps to editor { name: 'str-textarea', type: 'html' }. Output is HTML-as-string — markup is stored verbatim; sanitization happens at render time (server-side renderers / SDKs), not at write time.

Example

TypeScript
fields.html({
  label: 'Body',
  localizable: true,
  marks: ['bold', 'italic', 'link'],
  nodes: [
    'heading2',
    'bulletList',
    {
      type: 'callout',
      variants: [{ label: 'Highlighted', value: 'highlighted', icon: 'star' }],
    },
  ],
})

Options

OptionTypeRequiredDescription
label
string
Yes
Label shown to editors in Strife Studio.
localizable
boolean
No
When true, output is Record<string, string> instead of string.
propertyName
string
No
Override the stored property name.
placeholder
string | null
No
Hint text shown when the editor is empty.
marks
HtmlMark[]
No
Inline-formatting tools the editor offers.
nodes
HtmlNode[]
No
Block-level content the editor offers. callout, table and customComponent entries can carry their own configuration, and paragraph and heading entries a placeholder, see below.
structure
string
No
The blocks the field's content must have, in order, such as 'heading paragraph'. See Structure.

HtmlMark is one of: bold, italic, underline, strike, link.

HtmlNode is a bare HtmlNodeName (one of paragraph, heading1, heading2, heading3, blockquote, bulletList, orderedList, checkList, codeBlock, video, table, details, callout), a paragraph or heading entry with a placeholder, or a configured callout/table/customComponent object:

  • { type: 'paragraph' | 'heading1' | 'heading2' | 'heading3', placeholder: string }: the text Studio shows in an empty block of that type, such as { type: 'heading1', placeholder: 'Title' }. The entry offers its block as the bare name does. See Block placeholders. Needs @strifeapp/strife 2.3.0 or later.

  • 'callout' or { type: 'callout', variants: { label, value, icon? }[] }: the callout block, a box around blocks, typed by a CSS class on its <div>. A bare 'callout' offers Studio's four built-in types. With variants, label is the picker label (compiles to wire name), value becomes the CSS class token on the rendered callout, and icon is a Hugeicons name that Studio shows for the variant in its menus and on the callout. Both need @strifeapp/strife 2.0.0 or later.

    • A callout has one type. A stored callout with several classes keeps them until an author picks a type for it; the picked type then replaces every class that names a type, and other classes stay.
    • Studio offers four built-in types, listed before your variants: Info, Tip, Warning and Important, with the classes callout-info, callout-tip, callout-warning and callout-important. Studio colours them while editing, but the published HTML carries no colour, only the class: <div data-callout-classes="callout-warning" data-callout="" class="callout callout-warning">. Style .callout and each type's class on your site; Strife doesn't. See Styling callouts.
    • value must be a single class name that doesn't start with a digit: letters, digits, - and _. A variant with any other value, such as 'note wide', isn't offered.
    • A field whose menu isn't restricted offers callouts with the built-in types, plus your variants when it has this entry; the entry itself doesn't restrict the menu. Once marks or nodes restrict the menu, the field offers callouts only when nodes has a callout entry.
    • A callout keeps its classes and its title, lang and dir attributes. Any other attribute on a stored callout, such as id, style or a data- attribute of your own, is dropped once the field is edited and saved.
  • 'table' or { type: 'table', backgrounds?, borderColors?, borderWidths?, textSizes?, align?, verticalAlign? }: the table, with the choices its menus offer in Studio's new interface. Each list holds { label, value } entries: label is what editors see in the menu (compiles to wire name), and value is the named value Studio stores on the table or cell. backgrounds tint cells and striped rows or columns; borderColors and borderWidths are the colours and widths of the lines; textSizes are the text sizes a cell can have, such as a smaller size for notes. align: true and verticalAlign: true turn on horizontal and vertical alignment in the row and column menus; leave them out if your site's CSS doesn't style data-align and data-valign. Your site's CSS gives each value its look. See Tables. The configured entry needs @strifeapp/strife 2.4.0 or later, and so does a bare 'table' in a field that lists its nodes.

    • value must be a single class name that doesn't start with a digit: letters, digits, - and _, such as 'grey-light'. default and off are reserved for the menus' own None choices and refused. Each entry needs a label, a list takes at most 12 entries, and a value can't be in a list twice. Compiling your schema fails otherwise, and so does a field with two configured table entries.
    • Like a configured callout, the entry offers the table without restricting the menu: a field whose only node it is keeps all its tools. A bare 'table' counts toward the list that restricts the menu, like bulletList.
    • An entry without lists, { type: 'table' }, offers the table with no colours, line widths, text sizes or alignment in its menus.
  • { type: 'customComponent', components: { tag, label, attributes? }[] }: customer web components the editor may insert (e.g. a form embed distributed as a custom element, <lime-form form-id="...">). A bare 'customComponent' node name isn't valid: without components it would be a silent no-op. Each entry: tag is the custom-element tag name; label is the insert-menu label.

    • attributes: { name, label?, default? }[] — what an author may fill in on each inserted instance. name is the HTML attribute written to the markup, label names the field in the editor (defaults to name), and default pre-fills it on insert. The placeholder renders one field per declared attribute, so a page with several of the same component gives each one its own form-id — and an author fills in a value, never attribute syntax.
    • Declare an attribute with no default to get an empty field. Leaving a field empty writes no attribute at all, rather than name="".
    • The set is schema-owned: attributes you don't declare can't be added from the editor, and a component that declares none gets no editing affordance. Attributes already present on stored markup are preserved untouched whether or not the schema declares them.
    • defaultAttrs: Record<string, string> is the deprecated 0.11.0 spelling — { 'form-id': 'x' } means the same as [{ name: 'form-id', default: 'x' }], minus the field label. Existing schemas keep working; new ones should use attributes.
Warning:

Pilot-scoped today. tag must be one of a small set of element names the editor's parse-time allowlist already recognizes (currently Kalmar Energi's Lime forms, lime-form/simpli-form) — any other tag is dropped like any other unmodeled markup, same as an unrecognized HTML element pasted into the editor. Recognized elements always render as a static placeholder in Strife Studio — the editor never mounts or hydrates the real element, and never loads the customer's script — the real component only renders where the published HTML is actually rendered, on the customer's own site (which must already have its loader script installed there). There is no Strife Studio UI for customComponent yet — nodes (or hand-edited template JSON) is currently the only way to set it, same as quality under image above.

Note:

Studio offers a tool for each entry in marks and nodes, with these exceptions. Link is always offered. Inline code and the divider are offered only in a field that sets neither marks nor nodes. A table is offered in such a field, and in a field whose nodes has a bare 'table' or a configured table entry. video also needs a video library on the team. details is offered in every field, whether or not nodes lists it; see Collapsible sections. Studio has no tool for images; an image already in the stored HTML is kept.

Structure

structure sets the blocks a field's content must have, in order. A hero, for example, holds one heading and one paragraph:

TypeScript
fields.html({
  label: 'Hero',
  structure: 'heading paragraph',
  nodes: [
    { type: 'heading1', placeholder: 'Title' },
    { type: 'paragraph', placeholder: 'Introduction' },
  ],
})

The structure describes the whole content, so a block it doesn't allow can't be added. Name the blocks that may follow too:

  • 'heading paragraph': one heading and one paragraph, and nothing more.
  • 'heading paragraph block*': one heading and one paragraph first, then any blocks, in any order.
  • 'paragraph details+': an introduction, then one or more collapsible sections, as in an FAQ. The field needs nodes: ['details'], see below.

An empty field starts with the blocks the structure requires.

structure needs @strifeapp/strife 2.3.0 or later. The older documentSchema option still compiles to the same setting, but unchecked, and is deprecated: use structure and placeholder entries instead.

Names and operators

  • heading: a heading, in any level the field offers. A structure can't name a level: nodes: ['heading1'] is what makes it an h1.
  • paragraph, blockquote, bulletList, orderedList, checkList, callout and details.
  • block: any block the editor can hold, also one the field has no tool for. The field's tools still decide what an author can add.

Images, videos, tables, code blocks and custom components can't be named in a structure yet.

The operators are * (any number), + (one or more), ? (optional), {2} (exactly two), {1,} (at least one), {1,3} (one to three), | (either) and parentheses, as in 'heading (paragraph | bulletList)+'.

What compiling checks

The SDK refuses a structure that would keep the field from working when it compiles your schema, and the error says what to change:

  • Every name must be a block the field offers. In a field that lists its tools in marks or nodes, add the block to nodes. That goes for details too, although Studio offers collapsible sections in every field.
  • A heading level, such as heading1, is refused. Write heading, and list the levels in nodes.
  • A structure may expand to at most 100 blocks. A range counts its blocks once per repeat, and a + counts them twice, as the editor builds them: 'paragraph{50}+' is 100.
  • A range that follows a * or + over the same blocks is refused as too complex for an editor to build, as in 'block* paragraph block{12}'. Each step of such a range doubles the work of building the editor.

In Studio

  • In the new interface, the / menu and Turn into offer only what keeps the content in its structure where the cursor is.
  • If all the content lacks is a heading or paragraph the structure requires, Studio adds it, empty: under 'heading paragraph+', a field that holds only a heading gets an empty paragraph. Other content that doesn't follow the structure, such as a page written before the field got it, opens as it is, without the structure, and nothing in it changes.
  • Studio's classic editor builds the field from the structure too.

Content written through the MCP server must follow the structure as well.

Block placeholders

A paragraph or heading entry in nodes can carry the text Studio shows in an empty block of that type, as in the hero above:

  • With a structure, the new interface shows the texts only in the blocks the structure requires: under 'heading paragraph block*', in the heading and the first paragraph, not in the blocks after them. Without a structure, it shows them in every empty block of the type.
  • A block's own text takes precedence over the field's placeholder, which stays the text for blocks without one.
  • Studio's classic editor shows the texts in every empty block of the type, and uses one text for every heading level: the first heading entry's.
  • A placeholder goes on a paragraph or heading1–heading3 entry. On any other entry, compiling the schema fails.

Placeholder entries need @strifeapp/strife 2.3.0 or later.

Styling callouts

Strife never styles a published callout; your site does. Give .callout a base rule that every callout gets, including your own variants and callouts without a type, and add a rule per type on top:

CSS
/* Every callout: your own variants and callouts without a type */
.callout {
  padding: 1rem 1.25rem;
  border-inline-start: 4px solid #94a3b8;
  background: #f8fafc;
}

/* Studio's built-in types */
.callout.callout-info { border-color: #3b82f6; background: #eff6ff; }
.callout.callout-tip { border-color: #22c55e; background: #f0fdf4; }
.callout.callout-warning { border-color: #eab308; background: #fefce8; }
.callout.callout-important { border-color: #ef4444; background: #fef2f2; }

/* Your own variants, e.g. value: 'highlighted' */
.callout.highlighted { border-color: #a855f7; background: #faf5ff; }

Keep the base rule. A site that styles only its own variants, such as .highlighted, shows a built-in type as plain text with no box. Studio's colours are for editing only, so choose your own.

Tables

A configured table entry in nodes sets the choices the table menus offer in the field. Each list is yours: offer only what your site's CSS styles, and leave out a list or flag you don't style:

TypeScript
fields.html({
  label: 'Body',
  nodes: [
    'heading2',
    'bulletList',
    {
      type: 'table',
      backgrounds: [
        { label: 'Light grey', value: 'grey-light' },
        { label: 'Dark grey', value: 'grey-dark' },
      ],
      borderColors: [
        { label: 'Black', value: 'black' },
        { label: 'Grey', value: 'grey' },
      ],
      borderWidths: [
        { label: 'Thin', value: 'thin' },
        { label: 'Thick', value: 'thick' },
      ],
      textSizes: [{ label: 'Small text', value: 'small' }],
      align: true,
      verticalAlign: true,
    },
  ],
})
OptionOffersStored as
backgrounds
Background for cells, and the tint of Stripes
data-bg, data-zebra-bg
borderWidths, borderColors
Lines, Line width and Line colour for the table, and Border for a row or column
data-border-width, data-border-color, data-border-top and the other sides
textSizes
Text size for cells
data-text
align
Horizontal alignment for a row or column
data-align
verticalAlign
Vertical alignment for a row or column
data-valign

Stripes is offered with backgrounds, and Lines with borderWidths or borderColors. Merging and splitting cells, the header row and column, and column widths are always offered: they're plain HTML (colspan, <th>, <colgroup>) and need no CSS of yours.

Studio's new interface stores a table as HTML, with each choice from the table menus as a named value in a data- attribute. A table with a header row, light grey stripes, thin black lines and one cell with its own background and bottom line is stored in this shape:

HTML
<table data-borders="outer inner-h" data-border-width="thin" data-border-color="black" data-zebra="rows" data-zebra-bg="grey-light">
  <colgroup><col style="width: 160px"><col style="width: 240px"></colgroup>
  <tbody>
    <tr><th colspan="1" rowspan="1"><p>Size</p></th><th colspan="1" rowspan="1"><p>Weight</p></th></tr>
    <tr><td colspan="1" rowspan="1"><p>Small</p></td><td colspan="1" rowspan="1" data-align="right"><p>2 kg</p></td></tr>
    <tr><td colspan="2" rowspan="1" data-bg="grey-light" data-border-bottom="thick black" data-text="small"><p>Weights are approximate.</p></td></tr>
  </tbody>
</table>

On the table:

AttributeValuesSet from
data-borders
outer, inner-h (between rows), inner-v (between columns), as a space-separated list; or none alone
Lines
data-border-width
a borderWidths value
Line width
data-border-color
a borderColors value
Line colour
data-zebra
rows or cols
Stripes
data-zebra-bg
a backgrounds value, the tint of the stripes
Stripes

On a cell, <td> or <th>:

AttributeValuesSet from
data-bg
a backgrounds value
Background
data-align
left, center or right
Horizontal alignment (row or column grip)
data-valign
top, middle or bottom
Vertical alignment (row or column grip)
data-border-top, data-border-right, data-border-bottom, data-border-left
"<width> <colour>": a borderWidths value and a borderColors value, such as "thin black"
Border (row or column grip)
data-text
a textSizes value
Text size
  • An attribute that isn't there means no choice: the site's standard look. None in a menu removes the attribute, except under Lines, where None stores data-borders="none" (no lines) and a table with no line choice keeps the site's standard lines.
  • A header row or header column is stored as <th> cells. A merged cell has colspan or rowspan.
  • Column widths are stored in <colgroup> as pixels, but they are proportions: a column's share of the table is its width divided by the sum of all the widths, so 160px and 240px mean 40 % and 60 %. Render them as percentages and the table keeps the proportions the editor showed at any width; Studio draws them the same way. Studio gives every column a width as soon as one is dragged, and a table nobody has resized has no widths: equal columns. Older content can have widths on only some columns; give each column without a width an equal share (100 % divided by the number of columns) and split the rest between the others by their widths.
  • Studio keeps a value no menu offers, such as one from another template, and writes it back unchanged when the field is saved. So the values your CSS meets aren't limited to the field's current lists.
  • In a field whose table has no lists (a bare 'table', or { type: 'table' }), the menus offer no lines, stripes, backgrounds, borders, text sizes or alignment: only the header row and column and merging.

Styling tables

Strife never styles a published table; your site does. Give tables a base rule, then a rule per attribute value. A rule for a value your field offers, such as grey-light or thick, is yours to name:

CSS
/* Every table */
.content table { width: 100%; border-collapse: collapse; }
.content th, .content td { padding: 0.5rem 0.75rem; vertical-align: top; }

/* Lines: data-borders */
.content table[data-borders~="outer"] { border: var(--table-line); }
.content table[data-borders~="inner-h"] tr + tr > * { border-top: var(--table-line); }
.content table[data-borders~="inner-v"] :is(td, th) + :is(td, th) { border-left: var(--table-line); }
.content table[data-borders="none"], .content table[data-borders="none"] :is(td, th) { border: 0; }

/* Line width and colour: your borderWidths and borderColors values */
.content table { --table-line-width: 1px; --table-line-color: #94a3b8; --table-line: var(--table-line-width) solid var(--table-line-color); }
.content table[data-border-width="thin"] { --table-line-width: 1px; }
.content table[data-border-width="thick"] { --table-line-width: 2px; }
.content table[data-border-color="black"] { --table-line-color: #000; }
.content table[data-border-color="grey"] { --table-line-color: #9ca3af; }

/* Stripes: data-zebra, tinted with data-zebra-bg */
.content table[data-zebra] { --table-stripe: #f3f4f6; }
.content table[data-zebra-bg="grey-light"] { --table-stripe: #f3f4f6; }
.content table[data-zebra="rows"] tr:nth-child(even) > * { background: var(--table-stripe); }
.content table[data-zebra="cols"] tr > :nth-child(even) { background: var(--table-stripe); }

/* Cells: backgrounds, alignment, your textSizes values */
.content :is(td, th)[data-bg="grey-light"] { background: #f3f4f6; }
.content :is(td, th)[data-align="center"] { text-align: center; }
.content :is(td, th)[data-align="right"] { text-align: right; }
.content :is(td, th)[data-valign="middle"] { vertical-align: middle; }
.content :is(td, th)[data-valign="bottom"] { vertical-align: bottom; }
.content :is(td, th)[data-text="small"] { font-size: 0.875em; }

/* A cell's own line: "<width> <colour>", so match both words */
.content [data-border-bottom~="thin"] { border-bottom-width: 1px; }
.content [data-border-bottom~="thick"] { border-bottom-width: 2px; }
.content [data-border-bottom~="black"] { border-bottom-color: #000; }
.content [data-border-bottom] { border-bottom-style: solid; }
/* … the same for data-border-top, data-border-right and data-border-left */

CSS can't turn the stored pixel widths into shares, so convert them where you render the HTML, for example:

JavaScript
// Column widths are proportions: px over the sum, as percentages.
for (const colgroup of root.querySelectorAll('table > colgroup')) {
  const cols = [...colgroup.children];
  const px = cols.map((col) => Number.parseFloat(col.style.width) || 0);
  const sum = px.reduce((a, b) => a + b, 0);
  if (sum > 0 && px.every((w) => w > 0)) {
    cols.forEach((col, i) => { col.style.width = `${(px[i] / sum) * 100}%`; });
  }
}

.content stands for the element your site renders the field's HTML into. Match the cell borders with ~=, which matches one word of the value, so that a width and a colour each need one rule rather than one per pair. Studio's look while editing is for editing only, so choose your own.

Collapsible sections

A collapsible section (details) is a line that always shows, the <summary>, with content under it that readers open and close. FAQ answers are a common use. Studio stores it in this shape:

HTML
<details class="details" open=""><summary>How long does delivery take?</summary><div data-type="detailsContent"><p>Two to three working days.</p></div></details>
  • open="" is there only while the section is open. Editors open and close sections while they edit, and the state they leave a section in is saved, so it is how your site shows it. A new section starts open.
  • Studio offers it in every rich text field, as Collapsible section, whether or not nodes lists details.
  • The summary holds text, with marks such as bold and links. The content holds blocks: paragraphs, lists, tables, callouts and so on. A stored summary whose text is wrapped in one block, such as <summary><p>…</p></summary>, keeps that text as the summary.
  • Studio writes a stored section back in this shape once the field is edited and saved. A section without class="details" or without the data-type="detailsContent" wrapper gets them, and any other attribute on <details>, <summary> or the wrapper is dropped.

Strife never styles a published section; your site does. Style details.details, its summary and [data-type="detailsContent"]. Browsers show a <details> without open closed until a reader opens it.

Output type

string (HTML), or Record<string, string> when localizable: true.

See also

  • Rich Content — the same editor, documented from the Strife Studio UI side.
  • fields.paragraph() — same underlying textarea component, but stores plain text instead of HTML.