Record label left — Form block

Free

form-record-label-left · for app, forms pages

Record label left

A record with many plain fields, as in settings: each label and its help on the left, its field on the right

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-record-label-left

Usage

Its demo data, shortened (Using blocks).

<script setup lang="ts">
import FormRecordLabelLeft from '@/components/trame/blocks/form/form-record-label-left.vue'

const props = {
title: "New product",
intro: "It stays saved as a draft until you publish it.",
fields: [
{
name: "name",
label: "Product name",
required: true,
placeholder: "Scented candle"
},
{
name: "category",
label: "Collection",
type: "relation",
help: "Where the product appears in the shop.",
options: [
{
value: "bougies",
label: "Scented candles"
},
{
value: "diffuseurs",
label: "Diffusers and room sprays"
}
],
search: "collection.options",
required: true
}
],
sections: [
{
id: "identity",
title: "Overview",
description: "What customers read first.",
fields: [
"name",
"category"
]
},
{
id: "sale",
title: "Price and stock",
fields: [
"price",
"stock"
]
}
],
submit: "product.create",
cancel: "product.list",
options: {
currency: "USD",
submitLabel: "Create product"
}
}
</script>

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

Props

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

PropTypeDescription
title*stringWordsthe record being created or edited ("New product", "Edit the amber candle")
introstringWordsone line under the title
fields*Field[]the form’s fields, in order
sectionsSection[]the sections shown, in order
valuesRecord<string, unknown>Datathe record’s current values by field name when editing, with its `id`; absent when creating (the fields start empty)
errorsRecord<string, string>Datawhat the server refused, by field name: the message says what to correct
submit*stringActionthe page action the form posts to; through the host it receives `{ data }` when creating, `{ id, patch }` (the changed fields) when editing; an image or file field carries the `File` picked (the host uploads it), `null` once removed. Posted natively, the form is multipart: `<name>` holds the new file, `<name>:remove` is "1" when the current one is removed
cancelstringActionwhere Cancel leads (the list or the record)
afterstringActionwhere the app goes once the record is saved (the record, the list): the host’s answer is its record
optionsOptionsthe block’s settings: layout choices and secondary words, read by every variant
Field fields[] · 12 props
PropTypeDescription
name*stringDesignthe key of the field in `values`, in `errors` and in what the form sends
label*stringWordsthe field’s name ("Product name")
type'text' | 'email' | 'tel' | 'url' | 'number' | 'money' | 'date' | 'time' | 'datetime' | 'textarea' | 'select' | 'switch' | 'radio-cards' | 'relation' | 'image' | 'file'text by default; money: an amount in the main unit with its currency; radio-cards: a few exclusive choices shown as cards; relation: another record chosen among the options the host answered; date "YYYY-MM-DD", time "HH:MM", datetime: a moment (an ISO date with its zone is shown in the browser’s own time once the page runs, one without is the wall time as written); image and file: what it holds now (its address, or `{ url, name, size }`) with a choice to remove it, and a dropzone for a new one
helpstringWordsone sentence on what the field is for, said under its label
placeholderstringWordsthe shape expected, never a value that looks real
optionsOption[]the choices, for a select or a relation
searchstringActionrelation: the query action the host answers as the user types (`{ q }` → `{ items: [{ value, label }] }`); the options are the first list
acceptstringDesignimage and file: the kinds the picker offers (".pdf,.jpg", "image/*"); any picture for an image by default
unitstringWordsa unit written after a number ("g", "days")
requiredbooleantrue: it must be filled in
readonlybooleantrue: the field is shown but cannot be changed
halfbooleanhalf the width on wide screens, two to a row (page)
Option fields[].options[] · 3 props
PropTypeDescription
value*stringDesignwhat is sent (the record’s id for a relation)
label*stringWordswhat is read
descriptionstringWordsradio-cards: one line under the label
Section sections[] · 4 props
PropTypeDescription
id*stringDesignthe section’s key
title*stringWordswhat the fields of the section are about ("Price and stock")
descriptionstringWordsone sentence under the title
fields*string[]Designa field name
Options options · 7 props
PropTypeDescription
submitLabelstringWordsthe save button ("Save the product")
cancelLabelstringWordsthe cancel link ("Cancel")
unsavedLabelstringWordsthe hint shown while edits are not saved ("Unsaved changes")
formErrorstringWordswhat the server said about the whole form, if it refused it ("The product could not be saved")
currencystringDesignISO 4217 for money fields, euro by default
markOptionalbooleanwrite "optional" after the optional fields, beside the "*" of the required ones
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 }
querya live read: a quick search, « see more »
gonavigates after a success
canwhether the page has this action
asseta picture’s address as your app serves it
Linkyour router’s link component
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.
rf.file.newNew, sent on saveNouveau, envoyé à l’enregistrement
rf.file.pickDrop a file here or click to choose oneGlissez un fichier ici ou cliquez pour le choisir
rf.file.removeRemoveRetirer
rf.file.removedWill be removed on saveSera retiré à l’enregistrement
rf.file.replaceTo replace it, drop another one or clickPour le remplacer, glissez-en un autre ou cliquez
rf.file.undoUndo this choiceAnnuler ce choix
rf.image.pickDrop a picture here or click to choose oneGlissez une image ici ou cliquez pour la choisir

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: fields[].search, record.save, cancel, after

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

  • 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.
  • Product editor side panel: Edit a product in a narrow workspace with a compact product preview above stacked controls.
  • Product editor variants grid: Prioritize the size and colour stock matrix for a product with multiple SKUs.
  • Responses table: Read the received answers in a table using the current field labels.

All 17 form blocks