Insight Cards
A number, how it moved and one line on why: spark bars, a trend delta and a short AI explanation.
PROGet Insight Cards and 168 other Pro components with pro lifetime — Get Pro
- Category
- Data & feedback
- Access
- ProPro · unlocked
- Source
- 202 lines · one file
- States
- 4 drawn
The decision inside it
Colour says good or bad, the arrow says up or down
A rise in failed sends is bad news. tone keeps the arrow honest about direction and lets the colour say whether the move is welcome, and the words are there for screen readers either way.
When to use it
Use Insight Cards for a headline number that needs a reason: the last few periods as bars, a delta, and one sentence on why it moved. Pass tone "negative" when a rise is bad, and noteLoading while the explanation is written.
Installation
How you get it
Paste this into Claude Code, Cursor, Codex or any coding agent. It installs the file and uses it as it is, instead of writing a new one.
Use Liro's Insight Cards for this.
Install it: npx shadcn@latest add @liro/insight-card
(the @liro registry is set up in components.json, with LIRO_KEY in .env.local)
Import it from @/components/ui/insight-card.
Do not rewrite or restyle it. Pass my data through its props
and keep its built-in states.For the full brief with every prop and the mistakes assistants usually make, use Copy prompt above. Pro components install through the @liro registry with your CLI token: see the Namespaced tab.
Usage
import { InsightCard } from "@/components/ui/insight-card";
export function WeekInsights({ note, writing }: { note?: string; writing: boolean }) {
return (
<div className="grid gap-3 md:grid-cols-3">
<InsightCard
label="Documents signed"
value="1,284"
delta={0.124}
deltaLabel="vs last week"
trend={[820, 905, 870, 1010, 1092, 1150, 1210, 1284]}
note={note}
noteLoading={writing}
/>
<InsightCard label="Failed sends" value="23" delta={0.64} tone="negative" trend={[12, 9, 14, 11, 13, 15, 19, 23]} />
</div>
);
}API reference
“Copy prompt” above puts a full brief on your clipboard, install command, dependencies, props, and the mistakes an assistant usually makes with this component.
Props
Read from the component’s own TypeScript interface when the site is built, so this table cannot drift from the file you install.
| Type | Notes | ||
|---|---|---|---|
label | string | Yes | – |
value | string | number | Yes | – |
delta | number | No | Change vs the previous period, as a fraction: 0.124 = +12.4%. |
deltaLabel | string | No | What the delta compares against. Default "vs last period". |
trend | number[] | No | The last few periods, oldest first. The last one is `value`'s period. |
trendLabels | string[] | No | A name per trend bar for the hover readout: "Mon", "Week 41". |
format | (v: number) => string | No | Formats the trend values in the readout. |
note | React.ReactNode | No | One sentence on why the number moved. |
noteLoading | boolean | No | The note is being written. |
tone | InsightTone | No | Whether the move is good. Default "auto": up is good. |
onExplain | () => void | No | Shows an Explain button when there is no note yet. |
className | string | No | – |
Dependencies
npm packages
clsxlucide-reacttailwind-mergeLiro foundations, installed alongside it
liro-themestateStates
All of them are drawn by the component. None is left for you to design.
- Default
- Writing the note
- Explain on request
- No change
Accessibility
- Keyboard reachable throughout, in visual order
- Focus trapped in overlays, Escape closes them
- Focus returns to whatever opened it
- Live regions announce what changed, not that something did
- Honours prefers-reduced-motion
Responsive behavior
- Sizes to its container, not the viewport
- Usable from 320px up
- Pointer-based interaction, so trackpad and touch both work
- No hover-only affordances