Getting started

Using blocks

Fill a block's props, pick the look that fits, and give it your app's links, words and actions through the host context.

A block is a whole page section: a hero, a pricing table, a checkout, a settings page. You give it your content as props, choose the block whose look fits, and your app answers what the block asks through one context.

Props

Each block has a props schema, schema.ts, installed with it under components/trame/core/blocks/…. Every block page on this site lists the props too, and the MCP server’s get_block gives them to your agent.

Every string in the schema has a nature, which says what goes in it:

Nature What it holds
copy Your words: a title, a sentence, a button label
media A picture’s address
action The name of an action your app resolves
data Records from your data: products, orders, rows
design A layout choice: an icon name, a numbering style

The content a block exists for is required: a steps block needs its steps. Everything else is optional, and a block hides what you leave out. Leave out a picture, and the block lays out without it. Leave out a rating, and no rating shows.

Looks of the same use

A block does one thing, in one look, in one file. Several blocks often serve the same use in different looks: they form a group, and the blocks of a group read the same props. Switch looks without changing your data:

<StepsCards :title="title" :steps="steps" />
<StepsVerticalRail :title="title" :steps="steps" />

Each block comes with one sentence that says when it fits, on its page and in the MCP server’s answers; its page lists the other looks of its group. A block may still choose a better fit for your data when it says so (for example, steps without pictures in a look built for pictures).

Options

options is always the last prop. It holds choices that do not change the block’s structure, read by every block of the group: alignment, columns, numbering. Most blocks take options.mood, which sets the section’s band (inverse, brand, warm or tint). See Styling.

<Steps :title="title" :steps="steps" :options="{ numbering: 'zero-padded', mood: 'tint' }" />

Demo data is an example

Every block ships demo data sets (demo.ts) for its previews and tests: one item, many items, long titles, a missing picture. They show the shape of the props, nothing more. Replace every word, picture and figure with your own before you publish. Do not keep a demo review, logo or number on a real page.

Actions

A prop of nature action holds a name, such as "start-trial" or "subscribe". The block never knows what is behind it: your app decides where it leads and what it does.

A block that changes something keeps a real <form method="post"> aimed at the action’s address. It works before the page hydrates, and in an app that handles nothing in the browser. When your app gives act, the block sends the form through it instead, shows a pending state, then the outcome or the error.

A control whose action your app does not have is not shown.

The host context

Your app is the block’s host. It gives the blocks one object:

Member Required What it does
href(action, record?) Yes The address an action leads to, or null
label(key, params?) Yes Your word for an interface key, or undefined to keep the block’s own
money(cents, currency?) Yes A formatted price. Amounts are always in cents
language No 'en' or 'fr': the language of the blocks’ own words. French when absent
asset(src) No A picture’s address as your app serves it
Link No Your router’s link component
can(action) No Whether the page has this action
act(action, payload?) No Run a change: subscribe, add to cart, save a record. Answers { ok: true } or { ok: false, error, message?, fields? }
query(action, args?) No A live read: a quick search, « see more »
go(action, record?) No Navigate after a success
cartCount, cartDrawer, cartOpen No The cart badge, whether you have a cart drawer, whether it is open

The payload a block sends to act holds only what the visitor typed or chose. Your app adds the rest: it already knows the record behind the action.

Without a host, blocks use a demo context: links point to #action, and the interface speaks French. Give them yours.

In Vue

Provide the host once, at the top of your app:

<script setup lang="ts">
import { provide } from 'vue'
import { BlockContextKey } from '@/components/trame/context'

provide(BlockContextKey, {
  href: (action) => ({ 'start-trial': '/signup', subscribe: '/newsletter' })[action] ?? null,
  label: () => undefined,
  money: (cents, currency = 'USD') => new Intl.NumberFormat('en-US', { style: 'currency', currency }).format(cents / 100),
  language: 'en',
})
</script>

In React

React blocks read the host through #context (see the #context mapping in Next.js or Vite (React)). Write the host once:

// host.ts
export const host = {
  href: (action: string) => ({ 'start-trial': '/signup', subscribe: '/newsletter' })[action] ?? null,
  label: () => undefined,
  money: (cents: number, currency = 'USD') =>
    new Intl.NumberFormat('en-US', { style: 'currency', currency }).format(cents / 100),
  language: 'en' as const,
}

In the browser, wrap your app in BlockHostProvider. This is where act, query and the cart go:

'use client'
import type { ReactNode } from 'react'
import { BlockHostProvider } from '#context'
import { host } from './host'

export function Providers({ children }: { children: ReactNode }) {
  return <BlockHostProvider host={{ ...host, act: async () => ({ ok: true }) }}>{children}</BlockHostProvider>
}

With Next.js server components, also call setBlockHost at the top of each page. Server components read only the plain functions (href, label, money, can, asset, Link):

// app/page.tsx
import { setBlockHost } from '#context'
import { host } from '../host'

export default function Page() {
  setBlockHost(host)
  return <main>…</main>
}

Motion

Blocks move only through shared motion presets, and each block has a budget: checkout, cart, account and app screens do not move at all; product and catalogue blocks only transition on hover, focus and open; marketing sections may reveal once; heroes and showcases may add decoration.

Set the level for the whole app on <html>:

<html data-motion="expressive">
Level What moves
none Nothing
no attribute The default: transitions and one-time entrances
expressive Also the decoration: parallax, tilt, marquee, scroll effects

When the visitor asks for reduced motion in their system, the durations drop to zero, whatever the level. Nothing auto-advances by default, anything that moves for more than a few seconds can be paused, and nothing keeps running on an idle page.

Accessibility

Every block is checked with axe at three widths, in light and dark, with nothing serious or critical. Blocks use real buttons and links, keep a visible focus and a full keyboard path. Content pictures need alt: when a schema has an alt prop, fill it with what the picture shows.

Every word a visitor reads is in the server HTML and visible before any script runs, so the page reads the same with scripts off or still loading.