Writing a component

A Handlebars template, a stylesheet and a prop schema — and the five constraints that are enforced rather than advised.

A component is three files with the same basename: a template, its styles, and a JSON file describing its props. It runs on the platform’s server and in every customer’s browser, so the constraints below are enforced at upload rather than left to review.

The template

Available: {{value}} (HTML-escaped), {{#if}}, {{else}}, {{#unless}}, {{#each}} with {{this}}, {{../parent}}, @index, @first, @last, and {{{slots.name}}} for a container’s children.

There are NO helpers. No partials, no {{#with}}, no {{lookup}}, no custom helper of any kind. A template that calls one throws into a swallowed empty string — so the section disappears from the page with nothing reported anywhere.

Which means a template cannot format a date, do arithmetic, compare two values, OR two conditions, slice an array or repeat a glyph. Anything of that kind is computed before the template sees it. The platform already does this for the values it owns — a period reading "2019 — Present", a star count, a year, a "has details" flag — and your component gets the same values.

The stylesheet

Your CSS is scoped automatically to #cmp-<instanceId>, so you write selectors as if the component owned the page. :root, html and body are rewritten to the component root. @media, @supports and @container are recursed into; @keyframes and @font-face pass through untouched.

The sanitizer strips the style attribute, so a dynamic value cannot go in style="". This is the single most common thing an author tries first.

<div class="grid" data-cols="{{columns}}">
Put it on a data attribute and select it in CSS instead.
.grid[data-cols="3"] { grid-template-columns: repeat(3, 1fr); }

When a value is continuous rather than a handful of options — a percentage, say — have the platform round it to a step first. The skill bars in the shipped themes are drawn with twenty-one rules and no JavaScript for exactly this reason.

Props and colours

Each prop declares a type, a label in both languages, and a default. A default a visitor reads needs defaultAr as well — it is what appears on the page before the owner has typed anything.

A colour prop is how a customer overrides a theme token. Declare it with an EMPTY default and a themeVar, then read it with a fallback. The empty default is the mechanism: nothing is emitted until the customer sets a value, so the token shows through.

.card { background: var(--cmp-surface, var(--theme-surface)); }

A colour prop whose default is a hex literal permanently overrides the theme. That was a real defect in this platform: nothing a customer changed in their appearance settings ever reached a published page, because a seeded default won every time.

Live data

A component with a dataSource renders the customer’s own content. Without one it renders its prop defaults forever — it will never show their name, their bio or their projects.

{
  "dataSource": "experience",
  "dataMapping": { "items": "experience" }
}

The merge is: registry defaults, then the theme’s config, then live data. So a key your dataMapping fills must NOT also appear in the theme’s config — the value would be computed and then discarded. Validation refuses that rather than leaving you to wonder why your text never appears.