SearchCtrlK

  • ↑↓navigate
  • ↵open
  • escclose

Can’t find it? Contact us

On this page

PromoCode

The promo code box of a cart or checkout.

  • WALLS10 10% off prints
Have a promo code?

SUMMER24 ended on 31 August.

View code
tsx
<PromoCode
	action="/cart/promo"
	value={submission?.code}
	error={submission?.error}
	applied={cart.codes.map((code) => ({
		code: code.code,
		label: code.description,
		remove: { action: "/cart/promo/remove", fields: { code: code.code } },
	}))}
	labels={{ toggle: "Have a promo code?", field: "Promo code", apply: "Apply", remove: "Remove" }}
/>

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 { PromoCode } from "@sdxc/ui/commerce";

Renders the applied codes first, then the disclosure, open whenever the reader has typed a code or the server refused one, so a failed post lands on the field with its error showing.

Props

Read from the component's own types, so every prop, every default and every allowed value is listed.

PropTypeRequiredDescription
actionstringYesWhere the code posts.
namestringNo
valuestringNoThe code the reader last sent, kept in the field after an error.
errorRemixNodeNoWhy the server refused the code; the field is marked invalid and described by it.
fieldsRecord<string, string>NoHidden fields the post carries, such as the page to return to.
appliedApplied[]No
labelsLabelsYes

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

@sdxc/ui

Can’t find it? Contact us