BlockDex

Components

Registries

Free blocks

Method

BlockDex

Components

Registries

Free blocks

Method

Open API

BlockDex

Components

Registries

Free blocks

Method

Open API

Components/fable-ui/metric-card

MetricCard

fable-ui/metric-card
FreeComponent

Display one trusted metric from a validated AI tool payload.

Live preview

live · rendered by the registry
Rendered by fable-ui on their own page — this is the component running, not a screenshot of it.

Install it

npx shadcn@latest add https://fable-ui.shobky.com/r/metric-card.json

Source

components/fable-ui/metric-card/metric-card.tsxfable-ui.shobky.com/r/metric-card.json
1import { cva, type VariantProps } from "class-variance-authority"
2
3import { Badge } from "@/components/ui/badge"
4import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"
5import { Skeleton } from "@/components/ui/skeleton"
6import { cn } from "@/lib/utils"
7
8export type MetricTrendDirection = "up" | "down" | "neutral"
9
10const metricCardVariants = cva("w-full max-w-md overflow-hidden transition-opacity", {
11 variants: {
12 variant: {
13 default: "bg-card shadow-sm",
14 elevated: "bg-card shadow-lg shadow-foreground/5",
15 subtle: "bg-muted/40 shadow-none",
16 },
17 size: {
18 sm: "",
19 md: "",
20 lg: "",
21 },
22 },
23 defaultVariants: {
24 variant: "default",
25 size: "md",
26 },
27})
28
29const metricContentSize = {
30 sm: { header: "p-4 pb-2", content: "p-4 pt-0", value: "text-3xl" },
31 md: { header: "p-5 pb-2", content: "p-5 pt-0", value: "text-4xl" },
32 lg: { header: "p-6 pb-3", content: "p-6 pt-0", value: "text-5xl" },
33} as const
34
35export interface MetricCardProps extends VariantProps<typeof metricCardVariants> {
36 label: string
37 value: string
38 trend?: {
39 direction: MetricTrendDirection
40 delta: string
41 }
42 context?: string
43 isLoading?: boolean
44 isDisabled?: boolean
45 error?: {
46 title: string
47 description?: string
48 }
49 className?: string
50}
51
52const trendClassName: Record<MetricTrendDirection, string> = {
53 up: "border-emerald-200 bg-emerald-100 text-emerald-700 dark:border-emerald-900/40 dark:bg-emerald-900/30 dark:text-emerald-400",
54 down: "border-red-200 bg-red-100 text-red-700 dark:border-red-900/40 dark:bg-red-900/30 dark:text-red-400",
55 neutral: "border-border bg-muted text-muted-foreground",
56}
57
58export function MetricCard({
59 label,
60 value,
61 trend,
62 context,
63 isLoading,
64 isDisabled,
65 error,
66 variant,
67 size,
68 className,
69}: MetricCardProps) {
70 const resolvedSize = size ?? "md"
71 const sizeClasses = metricContentSize[resolvedSize]
72 const hasMetric = label.trim().length > 0 && value.trim().length > 0
73
74 return (
75 <Card
76 className={cn(
77 metricCardVariants({ variant, size }),
78 isDisabled && "pointer-events-none opacity-50",
79 className,
80 )}
81 data-fable-ui="metric-card"
82 aria-busy={isLoading || undefined}
83 >
84 <CardHeader className={sizeClasses.header}>
85 <CardTitle className="break-words text-sm font-medium leading-none text-muted-foreground">
86 {isLoading ? <Skeleton className="h-4 w-28" /> : label || "Metric"}
87// … truncated

What it pulls in

npm packages

  • ai
  • zod
  • class-variance-authority

Other registry items

  • card
  • badge
  • skeleton
  • shobky/fable-ui/core

Files it writes

  • components/fable-ui/metric-card/metric-card.tsx
  • components/fable-ui/metric-card/index.ts
  • lib/fable-ui/tools/show-metric-tool.ts
  • lib/fable-ui/manifests/show-metric.md

Facts

Registry
fable-ui
Type
registry:component
Access
Free
Files written
4
Licence
MIT
First indexed
2026-08-03
Last confirmed
yesterday

Go to the source

Docs on fable-ui fable-ui.shobky.com shobky/fable-ui on GitHub Raw registry item This item as JSON

More from fable-ui

All 10 items
Same registry, same kind — the ones you would have found next
ComponentRegistryKindAccessInstallsCommand
ConfirmationCardconfirmation-cardfable-uiComponentsFree2 deps · 4 files
FormCardform-cardfable-uiComponentsFree2 deps · 4 files
SuggestedActionssuggested-actionsfable-uiComponentsFree2 deps · 4 files
BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex

BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex

BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex