Skip to content

Machine-translated – improvements welcome. Suggest an improvement

Placeholders

Platzhalter (#1177) shows the placeholders of a text as clickable buttons – the same everywhere: in the title template and with “Composite” in the folder type, in the cards of automations (task, change field, call URL, send e-mail) and in the run templates. Nobody has to copy {field} names from a long line.

What it is for

Below every input that accepts placeholders such as {titel}. The placeholders appear with their understandable name, grouped by “General” and folder type.

Matching patterns in the pattern catalogue: D2 · No internal abbreviations, D5 · Terms from the glossary, C10 · Same things the same: repeat patterns, do not reinvent them.

How to use it

With How it works
Mouse A click inserts the placeholder in the last used field at the cursor (replacing a selection) and puts the cursor after it. If no field has been used yet, it goes to the end of the last registered one. On hover the tooltip shows the technical placeholder ({key}).
Keyboard Tab reaches every placeholder as a small button; Enter or Space insert it. Afterwards the cursor is in the field after the placeholder.
Touch The buttons are small Knopf (kind secondary); on phones they have the invisible 44 × 44 px tap area.

What it means

Every button stands for a value that is filled in when it runs – named the way the person knows the field (“Cancel by”), not with the technical name. In front stands the name of the group (“General”, “Contract”); a short addition (“only for Contract”) says when the value is filled.

States

State How it comes about How it looks
one group eintraege line with “Insert placeholder” in front
grouped gruppen one line per group with its name; empty groups are left out
with addition zusatz short quiet text after the name
mouse, focus – as for the button, kind secondary, small

“Placeholders” section of the pattern page: a text with placeholders, grouped by “General” and folder type

“Placeholders” section, dark

Accessibility

The placeholders stand in a group (role="group") with a name (beschriftung, default “Insert placeholder”); every named group is a group of its own with its name. Every placeholder is a button with its understandable name; the technical placeholder is only in the tooltip.

Code

Inserting at the cursor: usePlatzhalterEinsetzen() returns feld(name, wert, setze) and einsetzen(key). Attach feld(…) to every input that accepts placeholders:

const ein = usePlatzhalterEinsetzen();
<textarea {...ein.feld('text', karte.text, (x) => setze({ ...karte, text: x }))} value={karte.text} onChange={…} />
<Platzhalter einsetzen={ein.einsetzen} gruppen={…} />
Prop Purpose
gruppen { name?, eintraege }[] – one line per group with its name in front, e.g. “General” and one per folder type; empty groups are left out
eintraege { key, text, zusatz?, titel? }[]: key without braces, text understandable (field label), zusatz briefly after it (e.g. “only for Contract”), titel as tooltip (default: the technical placeholder {key})
einsetzen called with the key – usually einsetzen from usePlatzhalterEinsetzen
beschriftung name of the group for screen readers and shown in front; default “Insert placeholder”

With usePlatzhalterEinsetzen({ trenner: ' · ' }) the separator goes in front when inserting at the end of a non-empty text (as with “Composite”).

Files and tests

  • Building block: web/src/bausteine/platzhalter/Platzhalter.tsx, look: Platzhalter.module.css
  • Pattern page: web/src/bausteine/platzhalter/muster.tsx – section Placeholders