OptionGroup
Priced choices for something being ordered.
View code
<form id="item-form" data-base="1150">
<OptionGroup name="tortilla" title="Tortilla" hint="Pick one" required requiredLabel="Required"
choices={[{ value: "corn", label: "Blue corn", price: 0 }, { value: "flour", label: "Flour", price: 50, priceLabel: "+$0.50" }]} />
<OptionGroup name="extras" title="Extras" hint="Optional, up to 2" max={2} choices={extras} />
<button type="submit">Add <output data-options-total>$11.50</output></button>
<OptionsLive form="item-form" currency="USD" />
</form>Installation
An ordinary dependency: install it, import the theme once, and import the component where it is used.
npm add @sdxc/ui remiximport "@sdxc/ui/theme.css";Usage
import { OptionGroup } from "@sdxc/ui/commerce";Renders a group: its title, hint and Required badge in the legend, then one row per pick
with its price at the end. Every input carries data-price, which OptionsLive sums.
Props
Read from the component's own types, so every prop, every default and every allowed value is listed.
| Prop | Type | Required | Description |
|---|---|---|---|
name | string | Yes | The field every pick posts as. |
title | string | Yes | |
hint | string | No | A line under the title, such as "Pick one" or "Optional, up to 3". |
required | boolean | No | Takes exactly one pick, drawn as radios; otherwise checkboxes. |
max | number | No | How many checkboxes may be ticked; ignored when required. @default 1 |
choices | Choice[] | Yes | |
defaultValue | string[] | No | The values ticked at first. |
requiredLabel | string | No | The badge a required group carries, such as "Required". |
Also accepts everything in Omit<TagProps<"fieldset">, "children" | "name">.