Calm motion: animations on this site only fade, with no movement
Coupon input
A field for a code, then the saving with a button to remove it
Lets a person type a discount code at checkout. Your server checks the code. If the server takes it, the field changes to a chip with the code and the saving. Use it with the order summary.
Basic
Order summary
- Home Studio hoodieSize M · BlackQty 1$48.00
- Pop filterQty 2$24.00
- Subtotal
- $72.00
- Shipping
- Free
- Total
- $72.00
- "Apply" or Enter emits
applywith the code. Withuppercase(on by default), the code is in capital letters. Check the code on your server. - While the server checks, set
loading. The button shows a spinner, and a second apply does not go out. - If the server takes the code, set
appliedto{ code, saving }. The field changes to a chip, and a hidden status line says that the code is applied. The remove button on the chip emitsremovewith the code. - If the server does not take the code, set
errorto the reason. The field shows it under the field and marks the field as not valid. - Change the words with
labelsor a label pack:label,apply, andremoveandapplied(functions of the code).
Usage
ts
import { BlessCouponInput } from "blessing-ui";API
Props
| Name | Type | Default | Description |
|---|---|---|---|
applied | BlessCoupon | — | the code that the shop took; with it, a chip shows in place of the field |
error | string | — | why the shop did not take the code |
loading | boolean | — | the shop is checking the code |
uppercase | boolean | true | write the code in capital letters |
labels | Partial<{ label: string; apply: string; remove: (code: string) => string; applied: (code: string) => string; }> | — |
Events
| Name | Payload | Description |
|---|---|---|
remove | [code: string] | |
apply | [code: string] |