# Metric bento

> A free three-cell analytics bento: headline numbers that roll when you change the period, a bar split into four channels and a live event list you can filter.

Analytics sections on landing pages often drop a flat PNG screenshot into a blurred box. Metric bento seats three live, interactive cells inside one hairline architectural frame: a lit KPI column that rolls totals and secondary rates across 7d, 30d, 90d and 12m windows, a proportional four-channel comparison bar coloured from your shadcn chart tokens that dims peers on hover, and a live event stream filtered in place with solid grey chips. Free and MIT-licensed so you can drop it into any landing page with one CLI command.

## Install

```bash
npx shadcn@latest add @hairline/metric-bento
```

Needs React 19, Tailwind CSS v4 and shadcn/ui theme variables (any style, light and dark). Icons from lucide-react.

- npm: `lucide-react`
- Hairline UI components it needs (the CLI installs them too): `number-roll`
- Docs and live preview: https://hairlineui.com/blocks/metric-bento
- Registry item (source): https://hairlineui.com/r/metric-bento.json

## Usage

```tsx
import { MetricBento } from "@/components/metric-bento";

<MetricBento
  eyebrow="Analytics overview"
  heading="Every number you check, on one surface."
/>
```

## Drop-in metrics bento on a SaaS landing page

Pass your own period snapshots, acquisition channels and event rows to replace static dashboard screenshots with live UI.

```tsx
import { MetricBento } from "@/components/metric-bento";

export function ProofSection() {
  return (
    <section className="mx-auto max-w-[1280px] px-4 py-16">
      <MetricBento
        eyebrow="Live telemetry"
        heading="Real product metrics without a 400 kB charting bundle."
      />
    </section>
  );
}
```

## Props

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `eyebrow` | `string` | `"Analytics overview"` | Plain label above the section heading. |
| `heading` | `string` | – | Primary display heading for the bento. |
| `subheading` | `string` | – | Short supporting sentence beneath the heading. |
| `periods` | `MetricPeriod[]` | – | Time window snapshots (e.g. 7d, 30d, 90d, 12m) driving the KPI column and channel share bar. |
| `channels` | `[MetricChannel, MetricChannel, MetricChannel, MetricChannel]` | – | Four channels paired with --chart-1..4. |
| `feedRows` | `MetricFeedRow[]` | – | Rows displayed in the bottom-right filterable event stream. |
| `accent` | `string` | `"var(--primary)"` | CSS colour or theme token tinting the lit hero KPI column. |

## States

- **period switch**: Glides the solid grey period indicator in 340ms, rolls all KPI figures via NumberRoll and transitions stacked share-bar widths smoothly.
- **channel inspect**: Hovering or focusing any bar segment or legend tile dims sibling channels to 28% opacity and displays exact share and growth delta.
- **stream filter**: Selecting a category radio chip filters the event rows immediately in place.
- **reduced motion**: Updates numbers and share-bar widths cleanly in place without transition travel.

## What it handles

Building a clean multi-cell metrics bento where one period switcher rolls every figure, resizes stacked share bars and pairs with a filterable live feed normally requires hand-wired layout and charting code.

- **Gliding period switcher**: Switches 7d, 30d, 90d and 12m with a solid grey measured indicator and rolls every metric with NumberRoll.
- **Interactive 4-channel share strip**: Draws proportional bars from --chart-1..4; hovering or focusing any channel dims peers and shows exact share and delta.
- **Filterable live event stream**: Filters events by category in place with neutral grey active chips and tabular mono status badges.
- **Lit hero KPI column**: Applies subtle token-tinted material to the headline KPI column while keeping peer cells crisp hairline.
- **Container-query responsive stack**: Reflows smoothly from 12-column desktop asymmetry into a clean single column on phones down to 320px.
- **Zero dependencies, MIT licensed**: Installs directly from the free @hairline registry with full light and dark theme token support.

## Replaces

static stat cards, stacked bar chart component, filterable activity feed

## Where it fits

- **Analytics & telemetry homepages**: Lets visitors toggle time windows and inspect live traffic sources without shipping a charting dependency.
- **Commerce & checkout SaaS pages**: Shows rolling GMV, conversion rate, payment-method share and real-time order events.
- **Developer tools & API dashboards**: Combines throughput totals, traffic source mix and live CLI/webhook logs in one tight section.
- **Metrics proof sections**: Replaces static three-number stat rows with interactive, theme-aware live proof.

## Notes

- Free and MIT-licensed: installs directly from /r/metric-bento.json with zero animation or charting dependencies.
- All controls expose semantic ARIA roles (tablist, radiogroup, focusable channel buttons) with full keyboard navigation.
- Reads shadcn card, background, muted, border and chart-1..4 variables in light and dark mode.

License: MIT (https://hairlineui.com/license#components)
