Componentform1.08 KB gzipZero dependencies
Coupon Field
Coupon code field with validation, success check and shake error.
Preview
Live Preview
Installation
Tokens guide →Add to your project via CLI (zero dependencies, code you own):
npx bigbullui add coupon-fieldOr install the full npm package:
npm install bigbulluiUsage
tsx3 lines
import { CouponField } from "@/components/ui/coupon-field"; <CouponField />Source code
coupon-field.tsx + 1 helperZero third-party dependencies (2 local files shown in tabs below).
tsxcoupon-field.tsx71 lines
"use client"; import * as React from "react";import { cn } from "./lib/utils"; export interface CouponFieldProps extends React.HTMLAttributes<HTMLDivElement> { onApply?: (code: string) => void; placeholder?: string;} /** Coupon code input: inline validation + voucher apply animation. */export function CouponField({ onApply, placeholder = "KUPON KODU", className, ...props }: CouponFieldProps) { const [code, setCode] = React.useState(""); const [state, setState] = React.useState<"idle" | "checking" | "valid" | "invalid">("idle"); const apply = () => { if (code.trim().length < 4) return; setState("checking");Props
Interactive Prop Playground
Tweak parsed AST props below to generate ready-to-paste JSX.
tsx3 lines
import { CouponField } from "@/components/ui/coupon-field"; <CouponField />| Prop | Type | Description |
|---|---|---|
| onApply | (code: string) => void | Callback invoked on apply. |
| placeholder | string | Placeholder text shown when empty. (Default: "KUPON KODU") |