Vibary.ai
← Vibe Coding

Coupon Apply

A valid code folds into a chip, a discount line opens in the summary, and the total falls.

commerceenergeticfriendlyinteraction · finite · intermediate · ~0.9s
Interactive · click to play
Variant

The animated component in this preview is rendered from the canonical file shown here. The surrounding demo shell only provides context and is not part of the copied code.

417 lines · react + motion only
import { useEffect, useRef, useState } from "react";
import { AnimatePresence, motion, useReducedMotion } from "motion/react";

/**
 * Vibary · Coupon Apply
 *
 * A valid code stops being something you typed and becomes something you
 * have: the field folds into a chip, a discount line opens in the

About this pattern

Three things have to happen the moment a code is accepted, and they have to happen in an order the eye can follow. The field crossfades into a chip in the same row, so nothing below it jumps; a discount line opens under the subtotal on a short eased height tween; and the total rolls downward — the new figure arriving from above and pushing the old one out of the slot, at a constant type size. Removing the code reverses all three. The chip carries its own remove control, which means the code stops being text you have to retype and becomes an object you can take off.

Promo code at checkoutReferral credit applied to a cartStudent or member discountLoyalty reward redeemed

Where it shows up

Screens we drew to show where this motion usually sits. Illustrations, not captures of any product.

  • 10:15
    Payment
    Card number4242 4242 4242 4242Name on cardN. Bergström
    Expiry04 / 28CVC•••
    Subtotal$156.00Shipping$0.00Tax$13.65Total$169.65
    Pay $169.65
    Checkout

    An accepted code becomes a removable chip and adds its own line to the summary.

Related patterns