Componentdata0.48 KB gzipZero dependencies
Cart Badge
Cart count badge that pulses on item add.
Preview
Live Preview
Installation
Tokens guide →Add to your project via CLI (zero dependencies, code you own):
npx bigbullui add cart-badgeOr install the full npm package:
npm install bigbulluiUsage
tsx3 lines
import { CartBadge } from "@/components/ui/cart-badge"; <CartBadge />Source code
cart-badge.tsx + 1 helperZero third-party dependencies (2 local files shown in tabs below).
tsxcart-badge.tsx44 lines
"use client"; import * as React from "react";import { cn } from "./lib/utils"; export interface CartBadgeProps extends React.HTMLAttributes<HTMLSpanElement> { count: number; /** Pulse animation trigger on count change */ pulseOnChange?: boolean;} /** Cart badge: animated pulse on quantity update. */export function CartBadge({ count, pulseOnChange = true, className, ...props }: CartBadgeProps) { const prev = React.useRef(count); const [pulse, setPulse] = React.useState(false); React.useEffect(() => { if (pulseOnChange && count !== prev.current) {Props
Interactive Prop Playground
Tweak parsed AST props below to generate ready-to-paste JSX.
tsx3 lines
import { CartBadge } from "@/components/ui/cart-badge"; <CartBadge />| Prop | Type | Description |
|---|---|---|
| count | number | Configures count. |
| pulseOnChange | boolean | Pulse animation trigger on count change |