139
A promo code field that checks your code, then either folds it into a tag while the savings line slides in and the total rolls down, or shakes once and says exactly why it failed.
akacoupon·promo code·discount code
Run this in any project set up for the shadcn CLI. It copies the Coupon Field source into your components folder, so the code is yours to change.
npx shadcn@latest add https://devl.dev/r/coupon-field.jsonImport it and render it. Every prop has a typed default, so it works straight away, and you pass your own data when you’re ready.
import { CouponField } from "@/components/coupon-field";
export default function Page() {
return <CouponField />;
}A free React component in the Commerce collection, written in TypeScript with Tailwind CSS on coss ui. MIT licensed.
Read from the Coupon Field source. Everything is optional unless it says required.
| Prop | Type | Default |
|---|---|---|
| lines | SummaryLine[] | [] |
| shipping | number | 0 |
| validaterequired | (code: string) => Promise<CouponResult> | — |
| onApplied | (code: string | null, savings: number) => void | — |
| currency | string | "USD" |
| locale | string | "en-US" |
| title | string | "Order summary" |
| className | string | — |