Option group editor inline — Form block
Proform-option-group-editor-inline · for app, settings pages
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
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-inlineUsage
Its demo data, shortened (Using blocks).
<script setup lang="ts">
import FormOptionGroupEditorInline from '@/components/trame/blocks/form/form-option-group-editor-inline.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>
<FormOptionGroupEditorInline v-bind="props" />
</template>Props
Each prop says who changes it: Words, Picture, Action, Design, Data.* required.
| Prop | Type | Description |
|---|---|---|
| title | string | Wordsthe editor’s heading, e.g. "Options and extras" |
| intro | string | Wordsone sentence on what the groups do, e.g. "What a customer chooses before adding this dish to the cart" |
| product | Product | the 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 |
| save | string | Actionsaves 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 |
| options | Options | the block’s settings: layout choices and secondary words, read by every variant |
Product product · 4 props
| Prop | Type | Description |
|---|---|---|
| id* | string | number | Datathe product’s id, sent with options.save |
| name* | string | Wordsthe product’s name, e.g. "Margherita pizza" |
| price* | number | its base price, in cents: the preview adds the options to it |
| currency | string | DesignISO 4217, EUR by default |
Group groups[] · 8 props
| Prop | Type | Description |
|---|---|---|
| id | string | number | Datathe group’s id, sent back with options.save |
| name* | string | Wordsthe group’s name, e.g. "Size" or "Extra toppings" |
| choice* | 'single' | 'multi' | single: the buyer picks one option; multi: several |
| required | boolean | true: the buyer must choose before adding to the cart |
| min | number | multi and required: the fewest options to pick; 1 by default |
| max | number | multi: the most options to pick; absent: no limit |
| active | boolean | false: kept here but not shown to buyers |
| options* | Option[] | the options, in the order the buyer sees them |
Option groups[].options[] · 4 props
| Prop | Type | Description |
|---|---|---|
| id | string | number | Datathe option’s id, sent back with options.save |
| name* | string | Wordsthe option as the buyer reads it, e.g. "Large" or "Extra cheese" |
| price | number | what it adds to the product’s price, in cents; 0 or absent: no change, negative: less |
| available | boolean | false: out of stock for now, shown to the buyer but not choosable |
Options options · 2 props
| Prop | Type | Description |
|---|---|---|
| saveLabel | string | Wordsthe save button, e.g. "Save options" |
| mood | 'inverse' | 'brand' | 'warm' | 'tint' | string | a 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).
| Member | What it is for |
|---|---|
| href | the address an action leads to, or null to hide what leads there |
| act | runs a change (subscribe, add to cart, save) and answers { ok } or { ok: false, error } |
| can | whether the page has this action |
| money | formats a price, given in cents |
| cartCount | the cart badge’s number |
| cartDrawer | whether your app has a cart drawer |
| cartOpen | whether the cart drawer is open |
| label | your 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:
| Key | English | French |
|---|---|---|
| newsletter.already | You are already subscribed. | Vous êtes déjà inscrit. |
| newsletter.done | Done: you are subscribed. | C’est noté : vous êtes inscrit. |
| newsletter.invalid | Check the email address. | Vérifiez l’adresse e-mail. |
| newsletter.tooMany | Too 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
optionsfrom 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
- 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.
- 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.