Site kit reference
This page is for whoever designs a Site's custom blocks: a web designer, or an AI agent such as Claude Code working for one. A custom block type is a set of fields, fixed words, an HTML template and CSS. CMS checks all of it when it is saved, the same way every time, and the Site draws it with no script of its own. The tables below are made from the same lists the checks use. To make, preview and publish a type, see Custom blocks.
How the Site draws a block
The template is checked when the type is saved and kept as a tree. When a page is shown, the Site puts the page's values into that tree, every value escaped as text, inside <div class="dd-block dd-x-CLASS">, where CLASS is the type's class name. Nothing is cleaned or guessed: anything the check doesn't accept is refused with its line and column, so fix it and save again.
Template
Write well-formed HTML: every element closed in order, every attribute value in quotes, a space between attributes, and nothing the browser would move (a <div> inside a <p>, a link inside a link, a <tr> without <tbody>). There is no script, form, frame, style, id, on… attribute or comment. A block's headings start at <h2>: the page has its own <h1>.
| Write | Shows |
|---|---|
| {{title}} | the field's value, as text; in text or in an attribute such as title or alt |
| {{item.name}} | a list item's field, inside an element with dd-each |
| {{t:more}} | one of the type's words, in the page's language |
| {{date:day}} | a date field as the page shows dates (Buddhist era in Thai) |
| dd-each="people" | the element once for each item of a list field |
| dd-if="photo", dd-if-not="photo" | the element only when the field has, or has no, value |
| dd-if="item.icon=search" | the element only when a choice field holds that option, such as one icon per item |
| <img dd-picture="photo"> | a picture from Media, with its sizes and its description |
| <div dd-rich="body"></div> | a rich text field, drawn by Dimdata, in an empty box |
On one element dd-each comes first: dd-if="item.photo" on the same element checks each item. A link is a fixed address (https, http, mailto, tel or a path on the Site such as /about) or exactly one link field: href="{{more}}". With target="_blank" the Site adds rel="noopener".
Elements
Attributes
The class attribute takes Site kit classes, your own class names (not starting dd-), and a choice field's key inside one of your own: class="card is-{{tone}}". A few names are the Site's own (mark, cover, brand, wrap, tone-tint and others): an element with one takes the Site's look for it too, so the editor warns and you give the class another name.
Fields
Behaviours
A block never runs its own script. For tabs, an accordion, a carousel, a counter or a part that fades in, switch on one of Dimdata's behaviours by name with dd-behaviour on the element that holds it. The name is written as is, never from a field. The check refuses an element that doesn't hold what its behaviour needs.
Every behaviour leaves the page complete without it: tabs show their panels one after another, an accordion's parts open on their own, a carousel still scrolls and swipes, a number shows as written and nothing stays hidden. Keyboard, screen readers and reduce motion are handled for you. The Site loads a behaviour's script only on pages that use it.
Its parts are yours to restyle in the block's CSS or the template's: .dd-tablist, .dd-tab ([aria-selected="true"] for the open one), .dd-carousel-controls, .dd-carousel-step and .dd-carousel-status. For example:
<div dd-behaviour="tabs">
<section dd-each="topics">
<h3>{{item.name}}</h3>
<div dd-rich="item.body"></div>
</section>
</div>CSS
Plain CSS, checked like a template's CSS (no @import, no other host's address, pictures and fonts only from /media/), then scoped to the block: .card becomes .dd-x-CLASS .card, and & is the block itself (&.wide, & > h2). A block's CSS can't reach the page around it: :root, html, body, & + …, & ~ …, nested rules, @font-face, @layer, @property and @page are refused. @media, @supports, @container and @keyframes are fine; a block's keyframes are renamed for it.
Use the Site's tokens so a block follows its template: var(--brand), var(--on-brand), var(--brand-text), var(--brand-tint), var(--ink), var(--ink-2) (softer text), var(--muted), var(--line), var(--line-strong), var(--tint) (the panel colour), var(--font-body) and var(--font-heading); for shapes, multiply your own corner size by var(--r-box) (cards, panels) or var(--r-control) (buttons), as in border-radius: calc(16px * var(--r-box)); var(--content-width) is the page's width.
A type whose Width is full reaches the screen's edges on a full-width page, and the Site pads it so its words line up with the page. Give & only top and bottom padding (padding-top, padding-bottom): left or right padding on & would undo the lining up. Blocks' CSS sits in its own layer, after Dimdata's utilities and before the template's CSS, so a template can still restyle a custom block.
Site kit v1
Utilities from Tailwind CSS 4.3.3, each with the Site's tw: prefix, built into every Site. Colours and corners are the Site's own, so they follow the template. A class outside the kit is refused, and the check names the nearest one. A screen width or a state goes after the prefix: tw:md:grid-cols-3, tw:hover:bg-brand-strong, never both at once.
Limits
Tips
- A block that opens the page, such as your own hero: set the page's title to hidden in its layout. The title stays the page's
<h1>for screen readers and search, and the block's<h2>shows as the heading. - Bands the width of the screen: set the page's width to full in its layout; blocks then fill it, and the block's own CSS can keep its words to a readable width.
- Space between blocks: the Site already puts about 4rem between blocks, so leave out a block's own outer padding (
tw:py-16) unless it has a background of its own. - What the kit doesn't have (a negative margin, a gradient, a
::beforenumber): write it in the block's CSS on the Site's tokens. - Copy as JSON and Paste JSON in the block type's More actions move a whole type at once, in the format of the JSON Schema above.
Library titles in a type's own layout
A field of the kind Library titles (two a type) shows titles from the Site's catalog in your own layout. On a page, an editor turns it on and pastes the address of a search on the Site (empty shows the newest titles), chooses how many (4 to 20) and whether they stay up to date, update once a day, or are a random few picked once a day. The template loops over the field with dd-each, and each title has only {{item.title}}, {{item.author}}, {{item.year}}, href="{{item.link}}", <img dd-picture="item.cover"> and {{item.kind}} (Book or E-book; its key book or ebook in a class or dd-if="item.kind=ebook"). Many titles have no cover, so give the cover's box a shape and a background and show the title in words too. Each titles field that is turned on counts as one of the page's six shelves, with its Title shelves and bookshelf tabs. The kind is offered with Library Manager or Publisher, and shows nothing in a footer block.
Film, maps and pages from other places
Give a type a field of the kind Film, map or page from another place and write an empty box for it: <div dd-embed="film"></div>. On a page, an editor pastes a YouTube, Google Maps or Facebook page address (or the embed code copied from one). The Site draws a 16 to 9 stage that says where it comes from, with a button: nothing loads from the other place until the visitor selects it, and without script it is a link. dd-cover="poster" on the same box shows a picture field first, and the box's title names the frame. Your CSS can give .dd-embed-stage another aspect-ratio. An address that is none of these places, or of the Site's own app addresses, draws nothing.
Icons
<span dd-icon="search"></span> draws one of Dimdata's icons, so a type holds no icon drawings of its own. The icon is as tall as its line and takes the color of the words around it; size it with a kit class such as tw:size-8, or with .dd-icon in the type's CSS. It is a decoration unless the span has an aria-label. For an icon an editor chooses, give a Choice from a list field options whose keys are icon names and write dd-icon="{{field}}" (or {{item.field}} in a list). The names: search, menu, close, check, add, arrow-up, arrow-down, chevron-left, chevron-right, open-in-new, link, download, upload, book, library, menu-book, article, newspaper, notes, image, school, people, groups, account, store, web, widgets, apps, dashboard, grid, chart, lightbulb, shield, lock, key, info, help, warning, error, bookmark, label, today, schedule, history, place, phone, email, translate, settings, tune, edit, code, swap, shipping, wallet, tablet, palette.
Newest posts in a type's own layout
A field of the kind Newest posts gives a block the Site's own newest posts of a content type, for a layout the standard Latest posts block doesn't have. The template loops over it with dd-each, and each item has item.title, item.summary, item.link, item.date (as {{date:item.date}}) and item.cover (as <img dd-picture="item.cover">), and nothing else. On a page, the editor chooses whose posts (a content type), how many (1 to 12) and, if wanted, one category. The Site reads the posts itself each time the page is drawn; a template never asks for data. A type has at most two such fields. dd-if="field" tests whether there are posts to show. The preview draws three made-up posts.
Example values
A type may carry example values in each language, "sample": { "th": { … }, "en": { … } }, shaped as a page's values for it (pictures by their Media id). The preview draws them in place of made-up ones, so a type is judged with real words. Visitors never see them, and pages keep their own values. An AI agent writes them with the type; to write or change them yourself, open the type's Example values tab, choose the language, and fill in the fields as you would on a page. Clear these example values goes back to made-up ones for that language.
Warnings
A save warns, without refusing, about an svg with no description (a <title>, aria-label, or aria-hidden="true" when it is only decoration), a link with no words for screen readers, and a heading that skips a level. Fix them: visitors with screen readers depend on them.
The CSS draws four more: side-by-side parts with no phone rule; an animation that keeps moving for visitors who ask for less motion (put it inside @media (prefers-reduced-motion: no-preference)); a focus outline taken away with no :focus-visible look in its place; and letter-spacing that also spreads Thai (write it under :lang(en)).
Updated