# PromoCode

> The promo code box of a cart or checkout: a "Have a promo code?" disclosure holding a POST form with one field, the server's error under it, and every code already applied as a chip with its own remove button.

```ts
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.

## Examples

```tsx
<PromoCode action="/cart/promo" error={state.error} value={state.code} applied={[{ code: "WALLS10", label: "10% off", remove: { action: "/cart/promo/remove", fields: { code: "WALLS10" } } }]} labels={{ toggle: "Have a promo code?", field: "Promo code", apply: "Apply", remove: "Remove" }} />
```

## Props

| Prop | Type | Description |
| --- | --- | --- |
| `action` | `string` | Where the code posts. |
| `name?` | `string` |  |
| `value?` | `string` | The code the reader last sent, kept in the field after an error. |
| `error?` | `RemixNode` | Why the server refused the code; the field is marked invalid and described by it. |
| `fields?` | `Record<string, string>` | Hidden fields the post carries, such as the page to return to. |
| `applied?` | `Applied[]` |  |
| `labels` | `Labels` |  |

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

