Builder preview — Form block

Pro

form-builder-preview · for app pages

Builder preview

Review the full respondent-facing form with a compact field outline beside it.

Documentation

Installation

One command copies the block into your project with the shadcn CLI (the registry is set once: Installation).

pnpm dlx shadcn-vue@latest add @trame/form-builder-preview

Usage

Its demo data, shortened (Using blocks).

<script setup lang="ts">
import FormBuilderPreview from '@/components/trame/blocks/form/form-builder-preview.vue'

const props = {
title: "Repair request",
description: "What we need to know to assess your item before the repair.",
fields: [
{
id: "article",
label: "Which item would you like repaired?",
type: "text",
required: true
},
{
id: "email",
label: "Your email address",
type: "email",
required: true
}
],
save: "form.save"
}
</script>

<template>
<FormBuilderPreview v-bind="props" />
</template>

Props

Each prop says who changes it: Words, Picture, Action, Design, Data.* required.

PropTypeDescription
title*stringWordsthe section’s heading
descriptionstringWordsa few words saying more, under the heading
fields*Field[]the form’s fields, in order
savestringActionsaves the form’s fields: shown once a field changed; through the host it receives `{ data: { fields } }`, the fields as edited; posted natively, `fields` holds them as JSON
optionsOptionsthe block’s settings: layout choices and secondary words, read by every variant
Field fields[] · 5 props
PropTypeDescription
id*stringDesignthe field’s key
label*stringWordsthe field’s name, as shown
type*'text' | 'email' | 'number' | 'textarea' | 'select'what kind of field it is: text, email, number, textarea, select
required*booleantrue: it must be filled in
choicesstring[]Wordsthe field’s choices, in order
Options options · 1 props
PropTypeDescription
mood'inverse' | 'brand' | 'warm' | 'tint' | stringa band of the page that redefines the theme surfaces inside it
What it asks your app for

The block never knows your app: it asks it, through one context provided once, where its links lead, what its actions do, how a price reads and which words to say (The host context).

MemberWhat it is for
hrefthe address an action leads to, or null to hide what leads there
actruns a change (subscribe, add to cart, save) and answers { ok } or { ok: false, error }
canwhether the page has this action
cartCountthe cart badge’s number
cartDrawerwhether your app has a cart drawer
cartOpenwhether the cart drawer is open
labelyour word for an interface key, or undefined to keep the block’s own

The words it says itself, in English and French; label(key) replaces any of them:

KeyEnglishFrench
newsletter.alreadyYou are already subscribed.Vous êtes déjà inscrit.
newsletter.doneDone: you are subscribed.C’est noté : vous êtes inscrit.
newsletter.invalidCheck the email address.Vérifiez l’adresse e-mail.
newsletter.tooManyToo many attempts, try again in a moment.Trop de tentatives, réessayez dans un moment.

Features

  • Every word in the server HTML
  • Same markup in Vue and React
  • Theme tokens only: every theme, light and dark
  • Shows what you give it, invents nothing
  • No motion; still under reduced motion
  • Real buttons and links, a visible focus
  • Asks your app through actions: record.save

A form section, for app pages; it uses @vueuse/core, class-variance-authority, clsx, tailwind-merge.

More form blocks

  • Contextual side cards: a form whose author needs help or a check while typing: tips or a live summary of the record beside it.
  • Multi step accordion: short steps that read as sections (address, delivery, payment): collapsible cards, one open at a time, the phone default.
  • Multi step stepper top: a creation flow of three to five steps: numbered steps across the top, the form beside tips and a live preview.
  • Multi step wizard vertical: six steps or more, or long ones: a vertical step list on the left and a single card on the right.
  • Option group editor inline: every group as a card, one under the other, beside a preview of the whole product as the buyer will choose it: the options section of a product’s own edit page.
  • Option group editor list: one ruled row per group with its rule and options in words, moved up or down, opened one at a time to edit: a menu with many groups to put in order.
  • Option group editor sheet: the groups listed on the page and the one chosen open in a side sheet, its fields above the buyer’s preview and the save bar: a back office where a dish or a product is edited in a panel over its list.
  • Product editor full: Edit product content and ordered pictures beside publishing and pricing controls.

All 17 form blocks