Key Metrics Block (Astro)
contentbit/astro-key-metricsFreeComponent
Stat cards for scannable numbers.
Install it
npx shadcn@latest add https://contentbit.dev/r/astro-key-metrics.jsonSource
1---2import type { KeyMetricsData } from '@contentbit/blocks'3import type { ValidatedBlockNode } from '@contentbit/core'45interface Props {6 node: ValidatedBlockNode<unknown>7}89// Static map so Tailwind can see the class names.10const COLS: Record<number, string> = {11 1: 'sm:grid-cols-1',12 2: 'sm:grid-cols-2',13 3: 'sm:grid-cols-3',14 4: 'sm:grid-cols-4',15}1617const { node } = Astro.props18const data = node.data as KeyMetricsData19const cols = COLS[Math.min(data.rows.length, 4)]20---2122<div data-cb-styled class:list={['my-6 grid grid-cols-2 gap-3', cols]}>23 {24 data.rows.map((row) => (25 <div class="bg-card relative overflow-hidden rounded-lg border px-4 pt-4 pb-3.5">26 <span class="via-foreground/20 absolute inset-x-0 top-0 h-px bg-gradient-to-r from-transparent to-transparent" aria-hidden="true" />27 <div class="text-2xl font-bold tracking-tight tabular-nums sm:text-[1.75rem]">{row.value}</div>28 <div class="text-muted-foreground mt-1 truncate font-mono text-[11px] tracking-wide uppercase">{row.label}</div>29 </div>30 ))31 }32</div>
What it pulls in
npm packages
Files it writes
More from contentbit
All 20 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Callout Block (Astro)astro-callout | contentbit | Components | Free | 3 deps | |
| Comparison Block (Astro)astro-comparison | contentbit | Components | Free | 3 deps | |
| Content Renderer (Astro)astro-content-renderer | contentbit | Components | Free | 3 deps | |
| FAQ Block (Astro)astro-faq | contentbit | Components | Free | 3 deps | |
| Pros & Cons Block (Astro)astro-pros-cons | contentbit | Components | Free | 3 deps | |
| Quick Reference Block (Astro)astro-quick-ref | contentbit | Components | Free | 3 deps | |
| Steps Block (Astro)astro-steps | contentbit | Components | Free | 3 deps | |
| Tabs Block (Astro)astro-tabs | contentbit | Components | Free | 3 deps |
