Componentform1.08 KB gzipZero dependencies

Coupon Field

Coupon code field with validation, success check and shake error.

Preview

Live Preview
Open ↗

Installation

Tokens guide →

Add to your project via CLI (zero dependencies, code you own):

npx bigbullui add coupon-field

Or install the full npm package:

npm install bigbullui

Usage

tsx3 lines
import { CouponField } from "@/components/ui/coupon-field"; <CouponField />

Source code

coupon-field.tsx + 1 helper

Zero 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 />
PropTypeDescription
onApply(code: string) => voidCallback invoked on apply.
placeholderstringPlaceholder text shown when empty. (Default: "KUPON KODU")