SearchCtrlK

  • ↑↓navigate
  • ↵open
  • escclose

Can’t find it? Contact us

On this page

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

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

Usage

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

PropTypeRequiredDescription
actionstringYesThe page the form reads back, usually the cart itself.
namestringNo
valuestringNoThe postcode the options answer.
errorRemixNodeNoWhy the postcode gave no options; the field is marked invalid and described by it.
fieldsRecord<string, string>NoHidden fields the query keeps, such as the country.
optionsOption[]No
labelsLabelsYes

Also accepts everything in Omit<TagProps<"div">, "children">.

@sdxc/ui

Can’t find it? Contact us