Insight Cards
spectrumui/insight-cardsFreeBlock
Metric cards with spark bars, trend deltas, and an AI note.
Install it
npx shadcn@latest add https://ui.spectrumhq.in/r/insight-cards.jsonSource
1'use client';23import { Sparkles, TrendingDown, TrendingUp } from 'lucide-react';4import { cn } from '@/lib/utils';56const KEYFRAMES = `7@keyframes su-grow { from { opacity: 0.4; transform: scaleY(0.2) } to { opacity: 1; transform: none } }8`;910export interface Insight {11 id: string;12 label: string;13 value: string;14 change?: number;15 spark?: number[];16 note?: string;17}1819export type InsightCardsVariant = 'Grid' | 'Row';2021export interface InsightCardsProps {22 insights: Insight[];23 variant?: InsightCardsVariant;24 className?: string;25}2627export function InsightCards({ insights, variant = 'Grid', className }: InsightCardsProps) {28 return (29 <div30 className={cn(31 'w-full max-w-[520px] gap-2.5',32 variant === 'Grid' ? 'grid sm:grid-cols-2' : 'flex flex-col',33 className,34 )}35 >36 <style dangerouslySetInnerHTML={{ __html: KEYFRAMES }} />37 {insights.map((insight) => {38 const positive = (insight.change ?? 0) >= 0;39 return (40 <div41 key={insight.id}42 className="rounded-xl border border-black/[0.07] bg-white p-3.5 transition-[border-color] duration-150 hover:border-black/[0.14] dark:border-white/[0.08] dark:bg-[#0B0B0D] dark:hover:border-white/[0.16]"43 >44 <div className="flex items-start justify-between gap-3">45 <div className="min-w-0">46 <p className="truncate text-[11.5px] font-medium text-neutral-500 dark:text-neutral-400">47 {insight.label}48 </p>49 <p className="mt-1 font-mono text-[20px] font-medium tabular-nums tracking-[-0.5px] text-neutral-900 dark:text-neutral-50">50 {insight.value}51 </p>52 </div>53 {insight.spark && insight.spark.length > 0 && (54 <span aria-hidden className="flex h-8 items-end gap-[2px]">55 {insight.spark.map((point, index) => (56 <span57 key={index}58 className={cn(59 'w-[3px] origin-bottom rounded-sm transition-[height] duration-500 ease-[cubic-bezier(0.23,1,0.32,1)] motion-safe:animate-[su-grow_400ms_cubic-bezier(0.23,1,0.32,1)_both]',60 index === insight.spark!.length - 161 ? 'bg-neutral-900 dark:bg-neutral-100'62 : 'bg-black/[0.12] dark:bg-white/[0.16]',63 )}64 style={{65// … truncated
What it pulls in
npm packages
Files it writes
More from spectrumui
All 182 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Agent Planagent-plan | spectrumui | Blocks | Free | 1 dep | |
| Agent Stepsagent-steps | spectrumui | Blocks | Free | 1 dep · 2 files | |
| Approval Cardapproval-card | spectrumui | Blocks | Free | 1 dep | |
| Chat Empty Statechat-empty-state | spectrumui | Blocks | Free | 1 dep · 2 files | |
| Citation Sourcescitation-sources | spectrumui | Blocks | Free | no deps · 2 files | |
| Code Blockcode-block | spectrumui | Blocks | Free | 1 dep | |
| Conversation Listconversation-list | spectrumui | Blocks | Free | 1 dep | |
| Diff Viewdiff-view | spectrumui | Blocks | Free | 1 dep |
