Option group editor list — Form block

Pro

form-option-group-editor-list · for app, settings pages

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

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-option-group-editor-list

Usage

Its demo data, shortened (Using blocks).

<script setup lang="ts">
import FormOptionGroupEditorList from '@/components/trame/blocks/form/form-option-group-editor-list.vue'

const props = {
title: "Options and extras",
intro: "What a customer chooses before adding this dish to the cart.",
product: {
id: "margherita",
name: "Margherita pizza",
price: 950,
currency: "EUR"
},
groups: [
{
id: "size",
name: "Size",
choice: "single",
required: true,
options: [
{
id: "s26",
name: "26 cm",
price: 0
},
{
id: "s33",
name: "33 cm",
price: 300
}
]
},
{
id: "toppings",
name: "Extra toppings",
choice: "multi",
max: 4,
options: [
{
id: "t1",
name: "Buffalo mozzarella",
price: 250
},
{
id: "t2",
name: "Spicy salami",
price: 200
}
]
}
],
save: "options.save",
options: {
saveLabel: "Save options"
}
}
</script>

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

Props

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

PropTypeDescription
titlestringWordsthe editor’s heading, e.g. "Options and extras"
introstringWordsone sentence on what the groups do, e.g. "What a customer chooses before adding this dish to the cart"
productProductthe product the groups belong to; absent: the groups are edited on their own (a shared library)
groups*Group[]Datathe product’s choice groups as saved, in the order the buyer sees them
savestringActionsaves every group: through the host it receives `{ productId?, groups }` (each group with its `min` and `max` as numbers and its options’ prices in cents); posted natively the form carries `productId`, `g<n>.name`, `g<n>.choice`, `g<n>.required`, `g<n>.min`, `g<n>.max`, `g<n>.active`, `g<n>.o<m>.name`, `g<n>.o<m>.price` (in the main unit, "1.50") and `g<n>.o<m>.available`, numbered in the order shown. A group or an option left out was removed. Absent, or when the page lacks it, the groups are shown read-only
optionsOptionsthe block’s settings: layout choices and secondary words, read by every variant
Product product · 4 props
PropTypeDescription
id*string | numberDatathe product’s id, sent with options.save
name*stringWordsthe product’s name, e.g. "Margherita pizza"
price*numberits base price, in cents: the preview adds the options to it
currencystringDesignISO 4217, EUR by default
Group groups[] · 8 props
PropTypeDescription
idstring | numberDatathe group’s id, sent back with options.save
name*stringWordsthe group’s name, e.g. "Size" or "Extra toppings"
choice*'single' | 'multi'single: the buyer picks one option; multi: several
requiredbooleantrue: the buyer must choose before adding to the cart
minnumbermulti and required: the fewest options to pick; 1 by default
maxnumbermulti: the most options to pick; absent: no limit
activebooleanfalse: kept here but not shown to buyers
options*Option[]the options, in the order the buyer sees them
Option groups[].options[] · 4 props
PropTypeDescription
idstring | numberDatathe option’s id, sent back with options.save
name*stringWordsthe option as the buyer reads it, e.g. "Large" or "Extra cheese"
pricenumberwhat it adds to the product’s price, in cents; 0 or absent: no change, negative: less
availablebooleanfalse: out of stock for now, shown to the buyer but not choosable
Options options · 2 props
PropTypeDescription
saveLabelstringWordsthe save button, e.g. "Save options"
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
moneyformats a price, given in cents
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: options.save
  • Reads options from your app

A form section, for app, settings 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

  • 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.
  • 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.
  • 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.

All 17 form blocks