BLOCKS & TOKENS
guide
8 min read

Custom Studio Blocks, Tailwind Tokens & Patterns

Themes extend OpenDash Studio visually without writing custom React bundles: place declarative blocks under blocks/<slug>/, declare design variables in design_tokens, package reusable page layouts under patterns/, and run server hooks via Boa JS functions.js.

Custom Studio Blocks (block.json + render.html)

Every subdirectory under blocks/<slug>/ containing block.json and render.html is auto-discovered with namespaced ID <theme_id>/<slug>. Fields use Unified Field Schema directly (max 32 top-level / 48 leaf fields, 64 KiB props budget) and render with top-level hydrated variables in MiniJinja (such as {{ title }}, {{ image.url }}, {{ cta.url }}, and {{ od_icon(...) }}):

blocks/docs-code/block.json json
{
  "schema_version": 1,
  "id": "my-theme/docs-code",
  "title": "Docs Code Block",
  "category": "content",
  "icon": "file-text",
  "render": "render.html",
  "fields": [
    { "type": "text", "key": "filename", "label": "Filename", "max_chars": 80, "default": "Terminal" },
    { "type": "text", "key": "language", "label": "Language Badge", "max_chars": 24, "default": "bash" },
    { "type": "textarea", "key": "code_body", "label": "Code", "max_chars": 4000, "default": "./opendash serve" }
  ]
}
blocks/docs-code/render.html html
<div class="odc-code-box odc-docs-code" data-odc-code>
  <div class="odc-code-head">
    <span class="odc-mono">{{ filename }}</span>
    <span class="odc-code-lang">{{ language }}</span>
  </div>
  <pre><code>{{ code_body }}</code></pre>
</div>

Tailwind Support & design_tokens CSS Variables

Set "core_tailwind": true to reuse OpenDash's built-in responsive utilities, and define up to 200 custom tokens across five typed groups inside theme.json -> design_tokens: colors, fonts, radii, spacing, and shadows. OpenDash emits <style id="od-theme-tokens">:root{...}</style> automatically inside od_head() using prefixes --od-color-*, --od-font-*, --od-radius-*, --od-spacing-*, and --od-shadow-* (rejecting unsafe CSS like url(, @import, or ;).

Theme Patterns & Pattern Library

Declare reusable page compositions under patterns/<name>.json (schema_version: 1 + blocks AST) and list them in theme.json -> patterns with key, title, category, description, and file. Editors and Admins can browse and insert your theme patterns directly from the Studio Pattern Library without hand-editing JSON.

Theme Server Hooks via functions.js & Localization (.mo)

Add a "functions" block (api_version: 1) in theme.json paired with functions.js running inside an isolated Boa JS worker. Active themes automatically receive public content read plus theme-scoped kv_read / kv_write, can subscribe to render filters (render/head, render/footer, render/slot wired to {{ od_hook("slot") }}), declare Admin actions, expose scoped /p/{pkg}/* routes, and read Theme Secrets.

Theme Localization (.pot / .po / .mo) bash
# Extract translatable __() / _x() / _n() strings from templates and blocks
opendash --l10n-extract ./my-theme --out ./my-theme/languages/my-theme.pot --domain my-theme

# Compile translated PO catalog into <domain>-<locale>.mo (e.g. my-theme-vi.mo)
opendash --l10n-compile ./my-theme/languages/my-theme-vi.po \
  --out ./my-theme/languages/my-theme-vi.mo \
  --pot ./my-theme/languages/my-theme.pot

Next Steps

Edit Source URL:

Search OpenDash

Use Arrow keys & Enter to navigate Full search page →