ShippingEstimate
"What will shipping cost?" on a cart page.
Estimate shipping
- StandardArrives Tue 24 Nov£4.95
- Tracked 48Arrives Fri 20 Nov£6.50
- Express courierArrives tomorrow£12.00
View code
<ShippingEstimate
action="/cart"
value={url.searchParams.get("postcode") ?? undefined}
options={rates.map((rate) => ({
id: rate.id,
label: rate.name,
arrives: `Arrives ${formatDay(rate.arrives)}`,
price: rate.price === 0 ? "Free" : formatAmount(rate.price, "GBP"),
}))}
labels={{ field: "Postcode", submit: "Estimate", heading: "Estimate shipping" }}
/>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 { ShippingEstimate } from "@sdxc/ui/commerce";Renders the heading, the one-field form and, once a postcode is answered, the options as a list with the price end-aligned in tabular figures.
Props
Read from the component's own types, so every prop, every default and every allowed value is listed.
| Prop | Type | Required | Description |
|---|---|---|---|
action | string | Yes | The page the form reads back, usually the cart itself. |
name | string | No | |
value | string | No | The postcode the options answer. |
error | RemixNode | No | Why the postcode gave no options; the field is marked invalid and described by it. |
fields | Record<string, string> | No | Hidden fields the query keeps, such as the country. |
options | Option[] | No | |
labels | Labels | Yes |
Also accepts everything in Omit<TagProps<"div">, "children">.