Build an Analytics Dashboard with Sidebar, KPI Cards and SVG Charts in One HTML File

A responsive store analytics dashboard with a collapsible sidebar, four KPI cards with sparklines, and hand-drawn SVG line, donut and bar charts.

The prompt

Prompt
Act as a senior product designer who writes clean, accessible front-end code. Build Harbor Metrics, a store analytics dashboard for a fictional coffee roaster, Tidewater Supply Co., as one HTML page. Layout: a dark collapsible sidebar with a brand mark and five icon nav links; a top bar with a sidebar toggle, page title, date range line and a 7 / 30 / 90 day segmented control; four KPI cards (revenue, orders, conversion rate, average order value), each with a delta vs the prior period and a sparkline; a revenue line chart against the prior period; a traffic-sources donut; an orders-by-channel bar chart; and a recent orders table. Rules: 1) Draw every chart by hand in inline SVG from seeded, plausible sample data, and regenerate all figures when the range changes. 2) The line chart shows a crosshair tooltip on hover or touch, is keyboard focusable, steps through points with arrow keys and announces values in an aria-live region. 3) The sidebar collapses to an icon rail on desktop and becomes an off-canvas drawer with a scrim under 760px. Escape closes it and aria-expanded stays accurate. 4) Reflow from 360 to 1280px: 4, then 2, then 1 KPI columns. Charts redraw at their real width so labels stay legible. 5) Use slate ink, one blue accent plus four supporting hues, system fonts, rounded cards and tabular numbers. 6) Use no external assets or storage, and respect prefers-reduced-motion. Output format: one complete HTML file in a single code block, then 3 short ideas to extend it.

Example output

One HTML file. Save it and open it in any browser.Open full screen

Example: Harbor Metrics, a store analytics dashboard for a small coffee roaster.

  • Sidebar: Use the menu button to collapse it to an icon rail on desktop. On phones it slides in as a drawer; tap the scrim or press Escape to close it.
  • Date range: Switch between 7, 30 and 90 days to regenerate the KPIs, sparklines and all charts.
  • Revenue chart: Hover or tap it to see the crosshair tooltip. You can also Tab to it and use the arrow keys.
  • Resize test: Narrow the window to 360px to watch the cards and charts reflow.
Written by AI from this prompt. Your results will vary.

Tips and common edits

Why this works

  • Seeded sample data gives believable, repeatable numbers, so the charts look real and stay consistent between range switches.
  • Charts redraw at their container's pixel width, so axis labels stay readable on 360px phones instead of shrinking.
  • Exact breakpoints, drawer behavior and ARIA rules leave the model nothing to guess, so the layout and toggle work on the first try.

Paste into ChatGPT, Claude or Gemini. Save the reply's code as dashboard.html and open it in any browser, or view it in the chat's preview or canvas. Resize the window to check the phone layout.

Common edits

  • Swap the business, metric names and channel labels for a SaaS, newsletter or fitness brand, and change the accent hex for a new theme.
  • Add a dark mode toggle that flips the CSS variables, or add a fifth KPI card for refunds or churn.

Prompt details

By
Prompts-GPT editors
Published
How prompts are written and checked

Did this prompt work?

Keep exploring

More in Design