Skip to content

Dashboard

A project at a glance: the four numbers that matter with how they moved, traffic and errors over the chosen time, where the errors come from, whether every service is up, and what the team did.

import { StatGroup, LineChart, HorizontalBar, Health } from '@sypnia/ui/react'

On this page
  1. On a desktop
  2. On a phone
  3. A new project
  4. Skeleton
  5. When the charts cannot load
  6. When to use it
  7. For everyone
  8. Props

On a desktop

Change the time range: every number and chart follows.

northwind-shop

How the project is doing.

Requests880K+12% vs. the period before
Errors0.82%+0.2 pts vs. the period before
Slowest 5% wait182ms−14 ms vs. the period before
Storage8.2 GB+310 MB vs. the period before
Requests and errors
Every day
  • Answered
  • Failed
050K100K150KNov 11Nov 12Nov 13Nov 14Nov 15Nov 16Nov 17
View as table
AnsweredFailed
Nov 11117K1.3K
Nov 12107K1.2K
Nov 13133K974
Nov 14135K1.2K
Nov 15120K974
Nov 16140K719
Nov 17128K889
Where the errors come from
Failed requests by route
  • POST /v1/checkout2,957
  • GET /v1/products1,586
  • POST /v1/refunds1,370
  • GET /v1/orders/:id793
  • POST /v1/webhooks505
View as table
Name
POST /v1/checkout2,957
GET /v1/products1,586
POST /v1/refunds1,370
GET /v1/orders/:id793
POST /v1/webhooks505

Services

APIWorkingDatabaseQueries take twice as long since 14:10Sign-inWorkingFilesWorking
Oct 19, 2026Nov 17, 2026

What the team did

  1. AR

    Ana Ruiz deployed version 1.42

  2. LO

    Luis Ortega created the table refunds

  3. AR

    Ana Ruiz invited Kenji Mori

  4. MG

    Marta Gil changed the plan to Pro

Code
import { useMemo, useState } from 'react';
import {
  ActivityFeed, Button, Columns, EmptyState, Health, HorizontalBar, LineChart, Page, PageHeader, Panel, SegmentedControl, SkeletonWords, Stack,
  Stat, StatGroup, UptimeBar, UptimeBarSkeleton, useSypnia,
} from '@sypnia/ui/react';

// A project at a glance: the four numbers that matter with how they moved, traffic and errors over the chosen
// time, where the errors come from, whether every service is up, and what the team did. A new project with no traffic
// says what to do first instead of showing empty charts.
type Range = '24h' | '7d' | '30d';
const en = {
  title: 'northwind-shop', lead: 'How the project is doing.', range: 'Time range', ranges: { '24h': '24 hours', '7d': '7 days', '30d': '30 days' },
  requests: 'Requests', errors: 'Errors', p95: 'Slowest 5% wait', storage: 'Storage', vsBefore: 'vs. the period before',
  traffic: 'Requests and errors', trafficSub: (r: string) => `Every ${r === '24h' ? 'hour' : 'day'}`, ok: 'Answered', failed: 'Failed',
  byRoute: 'Where the errors come from', byRouteSub: 'Failed requests by route', services: 'Services', uptime: 'The last 30 days', team: 'What the team did',
  api: 'API', db: 'Database', auth: 'Sign-in', storageSvc: 'Files', up: 'Working', slow: 'Slower than usual', slowDetail: 'Queries take twice as long since 14:10',
  newTitle: 'No traffic yet', newBody: 'Numbers show here once your app calls the API. Connect your agent or install the SDK, and send the first request.', connect: 'Connect your agent', docs: 'Read the quick start',
  chartFail: 'These numbers could not be loaded. Try again in a minute.',
  acts: [['deployed', 'version 1.42'], ['created the table', 'refunds'], ['invited', 'Kenji Mori'], ['changed the plan to', 'Pro']],
};
const es: typeof en = {
  title: 'northwind-shop', lead: 'Cómo va el proyecto.', range: 'Periodo', ranges: { '24h': '24 horas', '7d': '7 días', '30d': '30 días' },
  requests: 'Solicitudes', errors: 'Errores', p95: 'Espera del 5 % más lento', storage: 'Almacenamiento', vsBefore: 'frente al periodo anterior',
  traffic: 'Solicitudes y errores', trafficSub: (r: string) => `Cada ${r === '24h' ? 'hora' : 'día'}`, ok: 'Respondidas', failed: 'Fallidas',
  byRoute: 'De dónde vienen los errores', byRouteSub: 'Solicitudes fallidas por ruta', services: 'Servicios', uptime: 'Los últimos 30 días', team: 'Lo que hizo el equipo',
  api: 'API', db: 'Base de datos', auth: 'Inicio de sesión', storageSvc: 'Archivos', up: 'Funciona', slow: 'Más lento de lo normal', slowDetail: 'Las consultas tardan el doble desde las 14:10',
  newTitle: 'Aún no hay tráfico', newBody: 'Las cifras aparecen aquí cuando tu app llame a la API. Conecta tu agente o instala el SDK, y envía la primera solicitud.', connect: 'Conecta tu agente', docs: 'Leer el inicio rápido',
  chartFail: 'No se pudieron cargar estas cifras. Intenta de nuevo en un minuto.',
  acts: [['desplegó', 'la versión 1.42'], ['creó la tabla', 'refunds'], ['invitó a', 'Kenji Mori'], ['cambió el plan a', 'Pro']],
};
const now = Date.UTC(2026, 10, 17, 15);
// Relative times («2 hours ago») are counted from the moment the page is drawn, so the server and the browser
// write the same words; dates that are shown as dates stay fixed.
const ago = (ms: number) => Date.now() - ms; // the words match; only the machine-readable dateTime differs by a moment

const wave = (n: number, base: number, amp: number, seed: number) => Array.from({ length: n }, (_, i) => Math.round(base + amp * Math.sin((i + seed) / 3.2) + amp * 0.4 * Math.sin((i * 7 + seed) / 1.7)));

export default function Dashboard({ state = 'ready' }: { state?: 'ready' | 'loading' | 'new' | 'error' }) {
  const { locale, format } = useSypnia();
  const c = locale.startsWith('es') ? es : en;
  const [range, setRange] = useState<Range>('7d');
  const n = range === '24h' ? 24 : range === '7d' ? 7 : 30;
  const x = useMemo(() => Array.from({ length: n }, (_, i) => {
    const d = new Date(now - (n - 1 - i) * (range === '24h' ? 3600e3 : 86400e3));
    return range === '24h' ? `${String(d.getUTCHours()).padStart(2, '0')}:00` : format.date(d).replace(/,? \d{4}$/, '');
  }), [n, range, format]);
  const scale = range === '24h' ? 1 : 24;
  const ok = wave(n, 4200 * scale, 1300 * scale, 1), bad = wave(n, 30 * scale, 18 * scale, 4).map((v) => Math.max(0, v));
  const loading = state === 'loading', empty = state === 'new', error = state === 'error' ? c.chartFail : undefined;
  const header = <PageHeader title={c.title} lead={c.lead} actions={<SegmentedControl label={c.range} value={range} onChange={setRange} options={(['24h', '7d', '30d'] as const).map((r) => ({ value: r, label: c.ranges[r] }))} />} />;
  if (empty) {
    return (
      <Page wide>
        {header}
        <Panel><EmptyState icon="chart-line" title={c.newTitle} actions={<><Button variant="primary" icon="agent" href="#connect-agent">{c.connect}</Button><Button icon="book" href="#docs">{c.docs}</Button></>}>{c.newBody}</EmptyState></Panel>
      </Page>
    );
  }
  const total = ok.reduce((a, b) => a + b, 0), fails = bad.reduce((a, b) => a + b, 0);
  return (
    <Page wide>
      {header}
      <StatGroup>
        <Stat loading={loading} label={c.requests} value={format.number(total, { notation: 'compact' })} delta={`+12% ${c.vsBefore}`} trend="good" />
        <Stat loading={loading} label={c.errors} value={format.percent(fails / total, 2)} delta={`+0.2 pts ${c.vsBefore}`} trend="bad" />
        <Stat loading={loading} label={c.p95} value="182" unit="ms" delta={`−14 ms ${c.vsBefore}`} trend="good" />
        <Stat loading={loading} label={c.storage} value={format.bytes(8.2 * 1024 ** 3)} delta={`+310 MB ${c.vsBefore}`} trend="flat" />
      </StatGroup>
      <LineChart title={c.traffic} subtitle={c.trafficSub(range)} x={x} loading={loading} error={error} area
        series={[{ id: 'ok', label: c.ok, data: loading ? [] : ok }, { id: 'failed', label: c.failed, data: loading ? [] : bad }]} formatValue={(v) => format.number(v, { notation: 'compact' })} />
      <Columns cols={2} stack>
        <HorizontalBar title={c.byRoute} subtitle={c.byRouteSub} loading={loading} error={error} items={loading ? [] : [
          { label: 'POST /v1/checkout', value: Math.round(fails * 0.41) }, { label: 'GET /v1/products', value: Math.round(fails * 0.22) },
          { label: 'POST /v1/refunds', value: Math.round(fails * 0.19) }, { label: 'GET /v1/orders/:id', value: Math.round(fails * 0.11) }, { label: 'POST /v1/webhooks', value: Math.round(fails * 0.07) },
        ]} formatValue={(v) => format.number(v)} />
        <Panel title={c.services}>
          <Stack gap={4}>
            {/* While loading, each service keeps its name; its state is unknown and its detail is a bar as long as the last one. */}
            <Health state={loading ? 'unknown' : 'up'} label={c.api} detail={loading ? <SkeletonWords>{c.up}</SkeletonWords> : c.up} />
            <Health state={loading ? 'unknown' : 'degraded'} label={c.db} detail={loading ? <SkeletonWords>{c.slowDetail}</SkeletonWords> : c.slowDetail} />
            <Health state={loading ? 'unknown' : 'up'} label={c.auth} detail={loading ? <SkeletonWords>{c.up}</SkeletonWords> : c.up} />
            <Health state={loading ? 'unknown' : 'up'} label={c.storageSvc} detail={loading ? <SkeletonWords>{c.up}</SkeletonWords> : c.up} />
            {loading ? <UptimeBarSkeleton periods={30} /> : <UptimeBar label={c.uptime} from={format.date(new Date(now - 29 * 86400e3))} to={format.date(new Date(now))} periods={Array.from({ length: 30 }, (_, i) => ({ label: format.date(new Date(now - (29 - i) * 86400e3)), state: i === 11 ? 'degraded' : i === 29 ? 'degraded' : 'up' }))} />}
          </Stack>
        </Panel>
      </Columns>
      <Panel title={c.team}>
        <ActivityFeed label={c.team} loading={loading} items={c.acts.map(([action, target], i) => ({ id: i, actor: { name: ['Ana Ruiz', 'Luis Ortega', 'Ana Ruiz', 'Marta Gil'][i] }, action, target, time: ago((i * 7 + 2) * 3600e3) }))} />
      </Panel>
    </Page>
  );
}

On a phone

On a phone the numbers sit two by two and the charts take the width.

A new project

No traffic yet: what to do first, instead of empty charts.

northwind-shop

How the project is doing.

No traffic yet

Numbers show here once your app calls the API. Connect your agent or install the SDK, and send the first request.

Skeleton

The real page: each number keeps its name, with value and change as long as theirs; the charts draw their first-load shapes, each service its name with its state unknown, and the activity its last items.

northwind-shop

How the project is doing.

Requests
Errors
Slowest 5% wait
Storage
Requests and errors
Every day
  • Answered
  • Failed
Where the errors come from
Failed requests by route

Services

APIDatabaseSign-inFiles

What the team did

When the charts cannot load

Each chart says so in its own frame; the rest of the page stays.

northwind-shop

How the project is doing.

Requests880K+12% vs. the period before
Errors0.82%+0.2 pts vs. the period before
Slowest 5% wait182ms−14 ms vs. the period before
Storage8.2 GB+310 MB vs. the period before
Requests and errors
Every day
  • Answered
  • Failed
Where the errors come from
Failed requests by route

Services

APIWorkingDatabaseQueries take twice as long since 14:10Sign-inWorkingFilesWorking
Oct 19, 2026Nov 17, 2026

What the team did

  1. AR

    Ana Ruiz deployed version 1.42

  2. LO

    Luis Ortega created the table refunds

  3. AR

    Ana Ruiz invited Kenji Mori

  4. MG

    Marta Gil changed the plan to Pro

When to use it

Use it when

  • The home of a project or an organization.
  • Four numbers at most at the top, each with how it moved and whether that is good.

Do not use it when

  • Empty charts for a new project: say what to do first.
  • Colour alone for good and bad: the deltas say it in words too.

For everyone

  • Every chart has a title, a subtitle and a table of its values for screen readers.
  • The time range is a segmented control; changing it changes every chart.
  • Services say their state in words: «Slower than usual», not only a colour.

Props

LineChartTypeDefault
seriesrequired Series[]
titlerequired ReactNode
xrequired

The positions along the horizontal axis: dates, hours, names.

string[]
area

Fills under each line with a light wash: for a quantity that accumulates.

boolean
empty ReactNode
error ReactNode
formatValue

How a value is written in ticks, tooltip and table. Defaults to a compact number in the person's language.

((v: number) => string)
height number
loading boolean
subtitle ReactNode
xLabel

The header of the first column of the table view: what `x` is.

string
HorizontalBarTypeDefault
itemsrequired { label: string; value: number; }[]
titlerequired ReactNode
empty ReactNode
error ReactNode
formatValue Fmt
height number
keepOrder boolean
label

The header of the first column of the table view.

string Name
loading boolean
loadingRows

On the first load (`loading` with no items): how many rows will come, drawn as rows of skeleton. Default 5.

number
subtitle ReactNode
HealthTypeDefault
staterequired "up" | "degraded" | "down" | "unknown"
detail ReactNode
label ReactNode
  1. On a desktop
  2. On a phone
  3. A new project
  4. Skeleton
  5. When the charts cannot load
  6. When to use it
  7. For everyone
  8. Props

    Search pages, sections and terms