bigbullui logobigbullui
Componentfeedback

Stock Status

Stock status badge: in stock, low stock pulse, sold out.

Preview

Live Preview
Son 3 ürünStokta · 50

Installation

Tokens guide →

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

npx bigbullui add stock-status

Or install the full npm package:

npm install bigbullui

Usage

import { StockStatus } from "@/components/ui/stock-status";

<StockStatus />

Source code

stock-status.tsx

Zero dependencies (only React + utils). Copy and paste directly into your project:

"use client";

import * as React from "react";
import { cn } from "./lib/utils";

export interface StockStatusProps extends React.HTMLAttributes<HTMLSpanElement> {
  /** mevcut stok */
  stock: number;
  /** az stok eşiği */
  lowAt?: number;
  labelInStock?: string;
}

/** Stok durumu göstergesi: var/az/yok + nabız animasyonu. */
export function StockStatus({ stock, lowAt = 5, labelInStock = "Stokta", className, ...props }: StockStatusProps) {
  const out = stock <= 0;
  const low = stock > 0 && stock <= lowAt;

  return (
    <span
      className={cn(
        "inline-flex items-center gap-1.5 rounded-full border px-2 py-0.5 font-mono text-[10px] uppercase tracking-wider",
        out ? "border-destructive/50 bg-destructive/10 text-destructive" : low ? "border-amber-500/50 bg-amber-500/10 text-amber-600" : "border-emerald-500/50 bg-emerald-500/10 text-emerald-600",
        className
      )}
      role="status"
      {...props}
    >
      <span
        className={cn(
          "size-1.5 rounded-full bg-current",
          !out && (low ? "animate-pulse motion-reduce:animate-none" : "animate-pulse motion-reduce:animate-none")
        )}
        aria-hidden="true"
      />
      {out ? "Tükendi" : low ? `Son ${stock} ürün` : `${labelInStock} · ${stock}`}
    </span>
  );
}

Props

PropTypeDescription
stocknumbermevcut stok
lowAtnumberaz stok eşiği
labelInStockstring