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.
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.jsonPrefer 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
| Prop | Type | Default | Description |
|---|---|---|---|
| heading | string | "Redeem a gift card" | Section heading. |
| description | string | "Enter your gift card code below..." | Supporting copy under the heading. |
| validCodes | GiftCardEntry[] | none | Demo codes the form checks the typed input against, along with the balance to show on a match. |
| className | string | none | Extra 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.
More Ecommerce Blocks
View all →wishlist-manager
Wishlist Manager
Saved-items list with stock-status badges, move-to-cart and remove actions, and a real empty state.
product-information-tabs
Product Information Tabs
Tabbed product details with Description, Features, Specifications, Reviews, and Shipping panels.
collection-showcase-grid
Collection Showcase Grid
A large featured-collection hero card alongside a grid of smaller supporting collection tiles.
shop-by-brand-grid
Shop by Brand Grid
A grid of bordered brand tiles with a wordmark-style name, product count, and a hover affordance.
sale-countdown-timer
Sale Countdown Timer
A live days/hours/minutes/seconds countdown in default, compact, or full-width banner layouts.
shipping-info-cards
Shipping Info Cards
A row of icon cards covering shipping, delivery, returns, and support promises.