Multi step accordion — Form block

Pro

form-multi-step-accordion · for app, forms pages

Multi step accordion

Short steps that read as sections (address, delivery, payment): collapsible cards, one open at a time, the phone default

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-multi-step-accordion

Usage

Its demo data, shortened (Using blocks).

<script setup lang="ts">
import FormMultiStepAccordion from '@/components/trame/blocks/form/form-multi-step-accordion.vue'

const props = {
title: "New order",
intro: "Three steps, then a summary before the order is created.",
steps: [
{
id: "customer",
label: "Customer",
hint: "Who is ordering?",
fields: [
{
name: "name",
label: "Customer name",
required: true,
placeholder: "First and last name"
},
{
name: "email",
label: "Email address",
type: "email",
required: true,
half: true
}
]
},
{
id: "delivery",
label: "Delivery",
hint: "Where and how?",
fields: [
{
name: "address",
label: "Address",
required: true
},
{
name: "zip",
label: "ZIP code",
half: true,
required: true
}
]
}
],
saveDraft: "save-draft",
submit: "create-order",
aside: [
{
title: "Tips",
kind: "tips",
items: [
"Confirm the address with the customer before submitting.",
"Express orders must be created before 2 p.m."
]
},
{
title: "Preview",
kind: "preview",
fields: [
"name",
"email"
]
}
]
}
</script>

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

Props

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

PropTypeDescription
title*stringWordsthe record being created ("New order")
introstringWordsone line under the title
steps*Step[]the steps shown, in order
valuesRecord<string, unknown>Dataa saved draft’s values by field name; an absent value leaves the field empty
saveDraftstringActionkeeps the values without creating the record: through the host it receives `{ data, draft: true }`
submit*stringActionthe page action that creates the record: through the host it receives `{ data, draft: false }`
asideAside[]cards beside the form, e.g. tips or a preview
optionsOptionsthe block’s settings: layout choices and secondary words, read by every variant
Step steps[] · 4 props
PropTypeDescription
id*stringDesignthe step’s key
label*stringWordsthe step’s name ("Delivery")
hintstringWordsa few words under the name ("Where to send it?")
fields*Field[]the form’s fields, in order
Field steps[].fields[] · 8 props
PropTypeDescription
name*stringDesignthe key of the field in `values` and in what the form sends
label*stringWordsthe field’s name ("Delivery address")
type'text' | 'email' | 'tel' | 'url' | 'number' | 'date' | 'textarea' | 'select' | 'radio' | 'switch'what kind of field it is: text, email, tel, url, number, date, textarea, select, radio, switch
helpstringWordsone sentence on what the field is for
placeholderstringWordsthe shape expected, never a value that looks real
optionsOption[]the choices, for a select
requiredbooleantrue: it must be filled in
halfbooleanhalf the width on wide screens, two to a row
Option steps[].fields[].options[] · 2 props
PropTypeDescription
value*stringDesignwhat is sent
label*stringWordswhat is read
Aside aside[] · 4 props
PropTypeDescription
title*stringWordsthe card’s heading ("Tips", "Preview")
kind*'tips' | 'preview'tips: a list of advice; preview: what will be created, echoing only what was typed
itemsstring[]Wordsone tip
fieldsstring[]Designpreview: the fields to echo, the first as the heading
Options options · 3 props
PropTypeDescription
submitLabelstringWordsthe final button ("Create the order")
reviewLabelstringWordsthe name of the last step ("Summary")
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, record.save

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

Built with

The components this block is made of; each one installs on its own too.

More form blocks

  • Builder preview: Review the full respondent-facing form with a compact field outline beside it.
  • Builder: Arrange fields and edit their settings alongside a live form preview, then save them in one go.
  • Contextual side cards: a form whose author needs help or a check while typing: tips or a live summary of the record beside it.
  • 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.
  • Product editor side panel: Edit a product in a narrow workspace with a compact product preview above stacked controls.

All 17 form blocks