Stat card
blacksite/stat-cardFreeComponent
KPI card with title, value, status badge and integrity bar.
Install it
npx shadcn@latest add https://blacksite.sh/r/stat-card.jsonSource
1import * as React from "react";23import { cn, clamp } from "@/lib/utils";4import { StatusBadge, type StatusBadgeProps } from "@/registry/blacksite/ui/status-badge";5import { Progress } from "@/registry/blacksite/ui/progress";67export interface StatCardProps extends React.HTMLAttributes<HTMLDivElement> {8 label: React.ReactNode;9 value: React.ReactNode;10 status?: StatusBadgeProps["status"];11 statusLabel?: string;12 /** Progress / integrity value 0–100. */13 progress?: number;14 progressTone?: "primary" | "success" | "warning" | "danger" | "info" | "gold" | "neutral";15 /** Text color tone for the value. */16 valueTone?: "default" | "success" | "warning" | "danger" | "info" | "primary" | "gold";17}1819const valueToneClass: Record<NonNullable<StatCardProps["valueTone"]>, string> = {20 default: "text-foreground",21 success: "text-success",22 warning: "text-warning",23 danger: "text-danger",24 info: "text-info",25 primary: "text-primary",26 gold: "text-gold",27};2829const StatCard = React.memo(30 React.forwardRef<HTMLDivElement, StatCardProps>(31 (32 {33 className,34 label,35 value,36 status,37 statusLabel,38 progress,39 progressTone = "primary",40 valueTone = "default",41 ...props42 },43 ref,44 ) => {45 return (46 <div47 ref={ref}48 className={cn(49 "border-border bg-card flex flex-col gap-2 rounded-md border px-3 py-2.5",50 "shadow-[var(--shadow-panel)]",51 className,52 )}53 {...props}54 >55 <div className="flex items-start justify-between gap-2">56 <span className="text-mono text-foreground-muted truncate text-[10px] tracking-[0.1em] uppercase">57 {label}58 </span>59 {status && <StatusBadge status={status}>{statusLabel}</StatusBadge>}60 </div>61 <div62 className={cn(63 "text-xl leading-tight font-semibold tracking-tight",64 valueToneClass[valueTone],65 )}66 >67 {value}68 </div>69 {typeof progress === "number" && (70 <Progress value={clamp(progress, 0, 100)} tone={progressTone} size="xs" />71 )}72 </div>73 );74 },75 ),76);77StatCard.displayName = "StatCard";7879export { StatCard };
More from blacksite
All 25 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| App headerapp-header | blacksite | Components | Free | no deps | |
| Badgebadge | blacksite | Components | Free | no deps | |
| Bar chartbar-chart | blacksite | Components | Free | no deps | |
| Buttonbutton | blacksite | Components | Free | no deps | |
| Cardcard | blacksite | Components | Free | no deps | |
| Chart tooltipchart-tooltip | blacksite | Components | Free | no deps | |
| Data listdata-list | blacksite | Components | Free | no deps | |
| Gantt timelinegantt-timeline | blacksite | Components | Free | no deps |
