ItemOptionsDialog
The dialog an item opens before it goes in the cart.
View code
<MenuItemCard dialog="item-al-pastor" name="Al pastor trio" price="$11.50" />
<ItemOptionsDialog
id="item-al-pastor"
action="/cart/add"
title="Al pastor trio"
description="Spit-roasted pork, charred pineapple, cilantro and onion."
base={1150}
currency="USD"
total="$11.50"
fields={{ item: "al-pastor" }}
quantity={{ label: "Quantity" }}
submitLabel={<>Add <span data-options-qty>1</span> to cart</>}
closeLabel="Close"
>
<OptionGroup name="tortilla" title="Tortilla" required requiredLabel="Required" choices={tortillas} />
<OptionGroup name="extras" title="Extras" max={3} choices={extras} />
</ItemOptionsDialog>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 { ItemOptionsDialog } from "@sdxc/ui/commerce";Renders the dialog, its form and its OptionsLive island. Without script the form still posts every pick; the button shows the base total until the server prices it.
Props
Read from the component's own types, so every prop, every default and every allowed value is listed.
| Prop | Type | Required | Description |
|---|---|---|---|
id | string | Yes | The dialog's id, which the item's button names with commandfor. |
action | string | Yes | Where the form posts. |
title | string | Yes | |
description | RemixNode | No | |
price | RemixNode | No | The item's price as the reader sees it, under the description. |
badges | RemixNode | No | Tags beside the price, such as dietary badges. |
media | RemixNode | No | A picture across the top, such as the dish. |
mediaBackground | string | No | The colour behind the picture. |
base | number | Yes | The item's base price in minor units, which the running total starts from. |
currency | string | Yes | The ISO 4217 code totals are written in. |
locale | string | No | |
fields | Record<string, string> | No | Hidden fields the post carries, such as the item id and the page to return to. |
children | RemixNode | No | The OptionGroups. |
quantity | { label: string; name?: string; max?: number } | No | A quantity field; omitted, the item is added one at a time. |
notice | RemixNode | No | A note above the add button, such as a warning that the cart will be replaced. |
submitLabel | RemixNode | Yes | The add button's words before the price, such as "Add to cart". Put a <span data-options-qty>1</span> in it to show the quantity live. |
total | string | Yes | The total the button shows before any pick, already formatted. |
disabled | boolean | No | Keeps the item from being added, such as while the shop is closed. |
closeLabel | string | Yes | The close button's name, such as "Close". |