Promo Code Apply
A promo code that validates, then lands its discount on the total itself, with the new number rolling in from below.
Build a promo code field that applies its discount to the order total. Structure: a code input row (tag icon, the code, a status slot on the right), then a summary - subtotal, an optional discount line, a rule, and the total. The rule that matters: the discount has to land ON the total. The total is the only number anyone is watching, and a confirmation banner elsewhere on the page makes the buyer scroll back to check the thing he was just promised. Sequence: 1. Type the code character by character, about 70ms each. Instant text reads as a prefilled field, and a prefilled field proves nothing about the flow. 2. A spinner appears in the status slot for about 900ms. Even if your check is local and instant, show it - skipping this makes acceptance look like nothing happened. 3. Accepted: the spinner swaps for a green check (spring, stiffness ~620), and the field border turns green, so acceptance is visible without reading the icon. 4. The discount line opens by animating its HEIGHT from 0, which pushes the total down as it appears - the two changes then read as one cause. 5. The total re-renders keyed on its value inside AnimatePresence mode="popLayout": the old number rolls up and out, the new one rolls in from below (spring, stiffness ~480). A silent text swap is invisible. Accessibility: the total is aria-live="polite". Under prefers-reduced-motion, render the applied state with no typing and no roll. Colors as tokens: paper surface, hairline borders, semantic green for the accepted state and the discount line. Build the component, not this demo of it. - Ambient motion that IS the component may loop: a drifting background, a marquee, a spinner while something is genuinely loading. - Do not add any timer, interval, loop or script that performs a person's action by itself. No auto-hover, no auto-click, no cycling through states, no pretend submitting, no replaying the interaction on a schedule. - Every state that answers a person waits for a real event from that person. - Placeholder copy and sample content are welcome. Simulated behaviour is not.