SearchCtrlK

  • ↑↓navigate
  • ↵open
  • escclose

Can’t find it? Contact us

On this page

OptionGroup

Priced choices for something being ordered.

TortillaPick oneRequired
ExtrasOptional, up to 2
View code
tsx
<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.

Terminal
npm add @sdxc/ui remix
typescript
import "@sdxc/ui/theme.css";

Usage

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

PropTypeRequiredDescription
namestringYesThe field every pick posts as.
titlestringYes
hintstringNoA line under the title, such as "Pick one" or "Optional, up to 3".
requiredbooleanNoTakes exactly one pick, drawn as radios; otherwise checkboxes.
maxnumberNoHow many checkboxes may be ticked; ignored when required. @default 1
choicesChoice[]Yes
defaultValuestring[]NoThe values ticked at first.
requiredLabelstringNoThe badge a required group carries, such as "Required".

Also accepts everything in Omit<TagProps<"fieldset">, "children" | "name">.

@sdxc/ui

Can’t find it? Contact us