An overview

A dashboard

7 min readWritten for your agentMarkdown

This recipe draws OverviewGrid arrangement="tiles-wide-pair"; the others (agent/layout-chooser.md) take the same slots. Your page fits another? Change the one prop:

  • card-grid (metrics: many): OverviewGridStats the headline numbers, across the row; OverviewGridWide one combined chart, across the row; children the other chart and list cards, an even grid.
  • chart-over-table (metrics: report): OverviewGridWide the one chart; children its filters and its table.
  • home-column (metrics: start): children a greeting, quick actions, a feed.

Copy the file below whole (src/screens/overview.tsx, say) beside frame.tsx (docs/screen-frame.md) and swap the sample rows for your data; keep the parts and their props. A display-size heading (PageHeader variant="display") with the period at its end: 7, 30 or 90 days in a SegmentedControl, Custom opening the DateRangePicker beside it. Under it, two columns (PageColumns): number tiles, each with its change on the period before, a short fact and a sparkline; ONE wide chart of two series with their legend; then a chart beside a list (OverviewGrid); what is due in the side column, which a phone shows first. Every figure is counted from the rows of the period picked, so a new period moves them all. Draw one combined chart, never one chart a series. A flow in and out over time (added and deleted, received and sent, stock in and out) is one stacked ChartBar with the outflow as negative numbers: its bars hang below the zero line. Light, dark, phone and desktop are the parts' own: add no class for them. A chart's colours are its series' order (chart-1 the accent, then chart-2 … chart-5; exactly two series paint the second in chart-pair): never give a series a colour of your own. A panel with no rows shows its CardList's empty words; tiles loading, a failed load: docs/screen-states.md.

Show the code283 lines
TSX
// src/screens/overview.tsx: the overview, the page `/` opens on
import { useState } from 'react';
import { AppFramePanel } from '@/components/goop/patterns/app-frame';
import {
  OverviewGrid,
  OverviewGridPair,
  OverviewGridStats,
  OverviewGridWide,
} from '@/components/goop/patterns/overview-grid';
import { PageColumns } from '@/components/goop/patterns/page-columns';
import { BarList } from '@/components/ui/goop/bar-list';
import { Card, CardDescription, CardHeader, CardTitle } from '@/components/ui/goop/card';
import { CardList } from '@/components/ui/goop/card-list';
import { ChartBar } from '@/components/ui/goop/chart-bar';
import { ChartLine } from '@/components/ui/goop/chart-line';
import { DateRangePicker } from '@/components/ui/goop/date-range-picker';
import { Item, ItemContent, ItemDescription, ItemEnd, ItemTitle } from '@/components/ui/goop/item';
import {
  PageHeader,
  PageHeaderActions,
  PageHeaderContent,
  PageHeaderDescription,
  PageHeaderTitle,
} from '@/components/ui/goop/page-header';
import { SegmentedControl, SegmentedControlItem } from '@/components/ui/goop/segmented-control';
import { Sparkline } from '@/components/ui/goop/sparkline';
import { StatTile } from '@/components/ui/goop/stat';
import { TrendChip } from '@/components/ui/goop/trend-chip';
import { ScreenFrame, ScreenTopBar } from './frame';

// ---- the days, with no date library: the app's one locale, the sample's today
const LOCALE = 'en-GB';
const TODAY = new Date(2026, 10, 20);
const dayAt = (offset: number) => new Date(TODAY.getFullYear(), TODAY.getMonth(), TODAY.getDate() + offset);
const offsetOf = (date: Date) => Math.round((date.getTime() - TODAY.getTime()) / 86_400_000);
const shortDay = (date: Date) => date.toLocaleDateString(LOCALE, { day: 'numeric', month: 'short' });
const daysAgo = (offset: number) => (offset === 0 ? 'today' : offset === -1 ? 'yesterday' : `${-offset} days ago`);

// ---- the sample data: swap it for yours. A row a day, oldest first, the last 180 days (a period and the one before)
const CUSTOMERS = ['Diallo Dental', 'Kvist Bikes', 'Ortega Physio', 'Haddad Bakery', 'Lund Optics'];
const DAYS = Array.from({ length: 180 }, (_, i) => {
  const offset = i - 179;
  const weekend = [0, 6].includes(dayAt(offset).getDay());
  const interviews = weekend ? i % 2 : 3 + ((i * 7) % 5) + Math.floor(i / 60);
  return {
    offset,
    customer: CUSTOMERS[(i * 3) % CUSTOMERS.length] ?? '',
    interviews,
    transcribed: Math.max(0, interviews - (i % 3)),
    minutes: interviews * (38 + (i % 4) * 6),
    signups: i % 11 === 0 ? 1 : 0,
    // in and out: what went out is negative, so its bar hangs below the zero line
    added: interviews * 2 + (i % 4),
    deleted: -(i % 5),
  };
});
const DUE = [
  { key: 'FW-117', title: 'Recruit 8 participants', due: 'Thursday' },
  { key: 'FW-113', title: 'Draft the interview guide', due: 'Friday' },
];
const PRESETS = [
  { value: '7', words: '7 days' },
  { value: '30', words: '30 days' },
  { value: '90', words: '90 days' },
] as const;
/** The furthest back a period may start: the one before it needs the rows behind it. */
const EARLIEST = -89;

type Day = (typeof DAYS)[number];
type Count = 'interviews' | 'transcribed' | 'minutes' | 'signups' | 'added' | 'deleted';
type Period = { preset: string; from: number; to: number };

// every figure is counted from the rows, never typed
const lastDays = (days: number): Period => ({ preset: String(days), from: 1 - days, to: 0 });
const rowsIn = (period: { from: number; to: number }) =>
  DAYS.filter((day) => day.offset >= period.from && day.offset <= period.to);
const sumOf = (rows: Day[], count: Count) => rows.reduce((sum, row) => sum + row[count], 0);
const changeOf = (now: number, before: number) => (before ? Math.round(((now - before) / before) * 100) : 0);
/** The rows a week at a time, the last week ending on the period's last day. */
function weeksOf(rows: Day[]): Day[][] {
  const weeks: Day[][] = [];
  for (let end = rows.length; end > 0; end -= 7) weeks.unshift(rows.slice(Math.max(0, end - 7), end));
  return weeks;
}
/** A chart's or a sparkline's steps: each day for a month or less, else each week. */
const stepsOf = (rows: Day[]) => (rows.length <= 31 ? rows.map((row) => [row]) : weeksOf(rows));
const stepRow = (step: Day[]) => ({
  step: shortDay(dayAt(step[0]?.offset ?? 0)),
  interviews: sumOf(step, 'interviews'),
  transcribed: sumOf(step, 'transcribed'),
  added: sumOf(step, 'added'),
  deleted: sumOf(step, 'deleted'),
});

export default function OverviewScreen() {
  const [period, setPeriod] = useState<Period>(lastDays(30));
  const [picking, setPicking] = useState(false);
  const length = period.to - period.from + 1;
  const rows = rowsIn(period);
  const before = rowsIn({ from: period.from - length, to: period.from - 1 });
  const versus = `vs the ${length} days before`;
  const steps = stepsOf(rows);
  const spark = (count: Count) => steps.map((step) => sumOf(step, count));
  const change = (count: Count) => changeOf(sumOf(rows, count), sumOf(before, count));

  const interviews = sumOf(rows, 'interviews');
  const transcribed = sumOf(rows, 'transcribed');
  const signups = sumOf(rows, 'signups');
  const minutes = sumOf(rows, 'minutes');
  const newest = rows.filter((row) => row.signups > 0).pop();
  const byStep = steps.map(stepRow);
  const busiest = byStep.reduce<(typeof byStep)[number] | undefined>(
    (best, row) => (!best || row.interviews > best.interviews ? row : best),
    undefined,
  );
  const step = rows.length <= 31 ? 'day' : 'week';
  const byCustomer = CUSTOMERS.map((label) => ({
    label,
    value: sumOf(
      rows.filter((row) => row.customer === label),
      'interviews',
    ),
  }));
  const range = `${shortDay(dayAt(period.from))} – ${shortDay(dayAt(period.to))}`;

  return (
    <ScreenFrame current="/">
      <AppFramePanel header={<ScreenTopBar title="Overview" />}>
        <PageColumns
          heading={
            <PageHeader variant="display">
              <PageHeaderContent>
                <PageHeaderTitle asChild>
                  <h1>Overview</h1>
                </PageHeaderTitle>
                <PageHeaderDescription>{`Interviews, transcripts and new customers, ${range}.`}</PageHeaderDescription>
              </PageHeaderContent>
              <PageHeaderActions>
                <SegmentedControl
                  aria-label="Period"
                  size="lg"
                  fit
                  value={period.preset}
                  onValueChange={(next) => {
                    if (next === 'custom') setPicking(true);
                    else setPeriod(lastDays(Number(next)));
                  }}
                >
                  {PRESETS.map((preset) => (
                    <SegmentedControlItem key={preset.value} value={preset.value}>
                      {preset.words}
                    </SegmentedControlItem>
                  ))}
                  <SegmentedControlItem value="custom">Custom</SegmentedControlItem>
                </SegmentedControl>
                <DateRangePicker
                  aria-label="Dates"
                  value={{ from: dayAt(period.from), to: dayAt(period.to) }}
                  onValueChange={(picked) => {
                    if (!picked?.from) {
                      setPeriod(lastDays(30));
                      return;
                    }
                    const from = Math.max(EARLIEST, Math.min(0, offsetOf(picked.from)));
                    const to = Math.max(from, Math.min(0, offsetOf(picked.to ?? picked.from)));
                    const usual = PRESETS.find((preset) => to === 0 && Number(preset.value) === to - from + 1);
                    setPeriod({ preset: usual?.value ?? 'custom', from, to });
                  }}
                  open={picking}
                  onOpenChange={setPicking}
                  presets={PRESETS.map((preset) => ({
                    label: `Last ${preset.words}`,
                    range: { from: dayAt(1 - Number(preset.value)), to: TODAY },
                  }))}
                  minDate={dayAt(EARLIEST)}
                  maxDate={TODAY}
                  today={TODAY}
                  locale={LOCALE}
                  clearLabel="Back to the last 30 days"
                />
              </PageHeaderActions>
            </PageHeader>
          }
          narrowFirst="aside"
          asideLabel="Due this week"
          aside={
            <Card variant="outline">
              <CardHeader>
                <CardTitle asChild>
                  <h2>Due this week</h2>
                </CardTitle>
              </CardHeader>
              <CardList aria-label="Due this week" empty={{ title: 'Nothing due this week' }}>
                {DUE.map((task) => (
                  <Item key={task.key} asChild>
                    <li>
                      <ItemContent>
                        <ItemTitle>{task.title}</ItemTitle>
                        <ItemDescription>{task.key}</ItemDescription>
                      </ItemContent>
                      <ItemEnd>{task.due}</ItemEnd>
                    </li>
                  </Item>
                ))}
              </CardList>
            </Card>
          }
        >
          <OverviewGrid arrangement="tiles-wide-pair">
            <OverviewGridStats aria-label="The period at a glance">
              <StatTile
                label="Interviews recorded"
                value={String(interviews)}
                trend={<TrendChip value={change('interviews')} />}
                comparison={versus}
                description={busiest ? `${busiest.interviews} in the busiest ${step}` : 'None in this period'}
                spark={<Sparkline area values={spark('interviews')} label="Interviews recorded over the period" />}
              />
              <StatTile
                label="Transcribed"
                value={String(transcribed)}
                trend={<TrendChip value={change('transcribed')} />}
                comparison={versus}
                description={`of ${interviews} recorded`}
                spark={<Sparkline area values={spark('transcribed')} label="Interviews transcribed over the period" />}
              />
              <StatTile
                label="New customers"
                value={String(signups)}
                trend={<TrendChip value={signups - sumOf(before, 'signups')} format="number" />}
                comparison={versus}
                description={newest ? `Newest joined ${daysAgo(newest.offset)}` : 'None in this period'}
                spark={<Sparkline area values={spark('signups')} label="New customers over the period" />}
              />
              <StatTile
                label="Hours recorded"
                value={String(Math.round(minutes / 60))}
                trend={<TrendChip value={change('minutes')} />}
                comparison={versus}
                description={`${interviews ? Math.round(minutes / interviews) : 0} minutes an interview`}
                spark={<Sparkline area values={spark('minutes')} label="Hours recorded over the period" />}
              />
            </OverviewGridStats>
            <OverviewGridWide>
              <ChartLine
                title="Interviews and transcripts"
                description={`Each ${step} of the period`}
                summary={`Interviews recorded against those transcribed over ${range}${busiest ? `: ${busiest.step} was the busiest, with ${busiest.interviews} interviews` : ''}.`}
                config={{ interviews: { label: 'Recorded' }, transcribed: { label: 'Transcribed', dashed: true } }}
                categoryKey="step"
                unit="interviews"
                locale={LOCALE}
                data={byStep}
              />
            </OverviewGridWide>
            <OverviewGridPair>
              <ChartBar
                variant="stacked"
                title="Recordings in and out"
                description="Added and deleted each week"
                summary={`Recordings added and deleted each week over ${range}.`}
                config={{ added: { label: 'Added' }, deleted: { label: 'Deleted' } }}
                categoryKey="step"
                unit="recordings"
                locale={LOCALE}
                data={weeksOf(rows).map(stepRow)}
              />
              <Card variant="outline">
                <CardHeader>
                  <CardTitle asChild>
                    <h2>Top customers</h2>
                  </CardTitle>
                  <CardDescription>Interviews in the period</CardDescription>
                </CardHeader>
                <BarList aria-label="Top customers" items={byCustomer} limit={5} locale={LOCALE} />
              </Card>
            </OverviewGridPair>
          </OverviewGrid>
        </PageColumns>
      </AppFramePanel>
    </ScreenFrame>
  );
}

Where would you like to start?

Free · now

The Goop plugin

A design system for your AI coding agent, so screen ten matches screen one.

/plugin marketplace add goop-so/skillsthen /plugin install goop@goopCodex, Cursor, ChatGPT, the Claude app and more: Connect Goop
FreePro

The components

Every part live, with its props, its keys and what an agent sees. Whole page and app templates, working with sample data.