Metric tile with a value and an optional trend delta.
Components
178
12 this release
Bundle
0 kb
Copy-owned
Errors
0.4%
0.2% vs last week
npx @agents-npm-packages/vibeui add stat --dir ./src/components/uiImport
import { Stat } from "@/components/ui/stat"Generated from the component's TypeScript types, so it always matches the source. * marks a required prop.
| Prop | Type | Default | Description |
|---|---|---|---|
| label* | string | — | Visible label. |
| value* | string | — | Controlled value. |
| delta | string | — | Change text shown under the value. |
| trend | "neutral" | "down" | "up" | "neutral" | Direction of the change: up, down or neutral. |
| className | string | — | Extra classes, merged with the component's own. |
import { ArrowDownRight, ArrowUpRight } from "@phosphor-icons/react/dist/ssr";
import { cn } from "@/lib/utils";
/** Metric tile with a value and an optional trend delta. */
export function Stat({
label,
value,
delta,
trend = "neutral",
className,
}: {
label: string;
value: string;
delta?: string;
trend?: "up" | "down" | "neutral";
className?: string;
}) {
return (
<div
className={cn(
"animate-fade-up rounded-lg border border-line bg-surface p-5 shadow-quiet transition-[transform,box-shadow,border-color] duration-300 ease-out hover:-translate-y-0.5 hover:border-line-strong hover:shadow-lift",
className,
)}
>
<p className="text-[13px] text-muted">{label}</p>
<p className="mt-2 text-[28px] font-medium leading-none tracking-[-0.04em] text-ink tabular-nums">
{value}
</p>
{delta ? (
<p
className={cn(
"mt-3 inline-flex items-center gap-1 text-xs font-medium",
trend === "up" && "text-pastel-sage-ink",
trend === "down" && "text-pastel-rose-ink",
trend === "neutral" && "text-muted",
)}
>
{trend === "up" ? <ArrowUpRight size={12} weight="bold" /> : null}
{trend === "down" ? <ArrowDownRight size={12} weight="bold" /> : null}
{delta}
</p>
) : null}
</div>
);
}
Exports Stat. Peer dependencies: clsx, tailwind-merge, @phosphor-icons/react.