Staaarter

Gift Card Redemption Form

A gift card redemption form for an account or checkout page: a labeled code input and a Redeem button that synchronously checks the typed code against a supplied list of valid demo codes, showing either a balance and success badge or an invalid-code message, entirely client-side with no network call.

By Staaarter Team
Ecommerce
Docs
Live preview

Docs

Installation

A real shadcn registry command, not a copy-paste stand-in: it fetches this block plus its button, badge dependencies and any missing npm packages, and installs them straight into your project.

npx shadcn add https://staaarter.com/r/gift-card-redemption-form.json

Prefer not to use the CLI? Copy the source from the Code toggle above into src/components/blocks/ecommerce/ecommerce6.tsx instead.

Usage

The file also exports ecommerce6Demo, the exact props behind the preview above. Spread it to get a working section in one line, then replace it with your own data.

import { Ecommerce6, ecommerce6Demo } from "@/components/blocks/ecommerce/ecommerce6";

export default function Page() {
  return <Ecommerce6 {...ecommerce6Demo} />;
}

Props

PropTypeDefaultDescription
headingstring"Redeem a gift card"Section heading.
descriptionstring"Enter your gift card code below..."Supporting copy under the heading.
validCodesGiftCardEntry[]noneDemo codes the form checks the typed input against, along with the balance to show on a match.
classNamestringnoneExtra classes for the outer section element.

Types

interface GiftCardEntry {
  code: string;
  balance: string;
}

Behavior notes

  • Redemption is genuinely synchronous and client-side: on submit, the typed code is trimmed and uppercased, then matched (case-insensitively) against `validCodes`; there is no loading state or fake delay because the check is instant, and no network call backs it.
  • A match shows a success card with the matched code's `balance` and a green-accented "Redeemed" badge; no match shows a red "Invalid or already-used code" message.
  • Editing the input after a result is shown clears the previous success/error state immediately, so a new attempt never shows a stale result next to freshly typed text.
  • The Redeem button is disabled only while the input is empty, it does not disable during checking since the check is instant.
  • Try GIFT-2450-JKPL, GIFT-8891-QRST, or GIFT-3327-WXYZ in the live preview for the success state, any other text triggers the error state.