Alerts 02

A dashboard alert card that plots one metric over the last hour against a dashed threshold line, showing the current value, threshold and peak, with an Acknowledge action and an optional runbook link. It is built on Recharts and reuses the shared Alerts and Chart Panel building blocks.

Alerts 02
LIVE · running in a sandboxed iframe
Installed with plain shadcn add · no workarounds · theme neutral (none shipped)
See how it was built

Installation

pnpm dlx shadcn@latest add @dashboardblocks/alerts-02

Requires @dashboardblocks in the registries of your components.json (shadcn adds official directory namespaces automatically).

Usage

usage.tsx
import { Alerts2 } from '@/components/dashboardblocks/alerts/alerts-02'<Alerts2  title='Error rate above threshold'  description='checkout-api · eu-west-1 · firing for 12 minutes'  metric='Error rate'  readings={readings}  severity='critical'  threshold={5}  formatter={(value) => `${value.toFixed(1)}%`}  runbookHref='/runbooks/checkout-error-rate'/>
  • Showing one metric's recent trend next to the threshold that triggers an alert, such as an error rate or latency SLO.
  • Surfacing an active incident on an overview dashboard where operators need to acknowledge it and jump to a runbook.
  • Pairing with alerts-01 or status-02 in an incident or monitoring section of a dashboard.
  • Displaying a firing or resolved alert where the peak value over the window matters for postmortems.

Examples

Using the bundled example props

Renders the component with the sample dataset exported by the registry item, which shows a firing error-rate spike above a 5% threshold.

using-the-bundled-example-props.tsx
import { Alerts2, alerts2ExampleProps } from '@/components/dashboardblocks/alerts/alerts-02'export default function Preview() {  return <Alerts2 {...alerts2ExampleProps} />}

Latency alert with a custom formatter

Shows a warning-level p95 latency alert in milliseconds with a rounded formatter and no runbook link, so the runbook button is hidden.

latency-alert-with-a-custom-formatter.tsx
import { Alerts2, type Alerts2Props } from '@/components/dashboardblocks/alerts/alerts-02'const readings: Alerts2Props['readings'] = Array.from({ length: 30 }, (_, index) => ({  label: `14:${String(index * 2).padStart(2, '0')}`,  value: 620 + Math.sin(index / 3) * 90 + (index > 20 ? (index - 20) * 25 : 0),}))export default function LatencyAlert() {  return (    <Alerts2      title='p95 latency degraded'      description='search-api · us-east-1 · pending for 6 minutes'      metric='p95 latency'      readings={readings}      severity='warning'      threshold={800}      formatter={(value) => `${Math.round(value)} ms`}    />  )}

Resolved alert inside a dashboard grid

Uses the resolved severity for a recovered alert and places the component in a responsive two-column grid.

resolved-alert-inside-a-dashboard-grid.tsx
import { Alerts2, alerts2ExampleProps } from '@/components/dashboardblocks/alerts/alerts-02'export default function ResolvedGrid() {  return (    <div className='grid gap-4 md:grid-cols-2'>      <Alerts2        {...alerts2ExampleProps}        title='Error rate recovered'        severity='resolved'      />    </div>  )}

API reference

PropTypeDefaultDescription
titlestring—Heading text shown in the card header.
descriptionstring—Secondary line under the title, typically the service, region and firing duration.
metricstring—Metric name used in the stat labels, chart series name, table caption and column header.
readings{ label: string; value: number }[]—Time-ordered samples for the last hour. The last item is treated as the current value and the maximum is used for the peak.
severityAlertSeverity ("resolved" | "info" | "warning" | "critical")—Severity passed to SeverityBadge. Switches to 'resolved' with an 'Acknowledged' label after the user acknowledges.
thresholdnumber—Threshold value drawn as a dashed reference line and used as the lower bound of the shaded breach band. Also included in the peak calculation.
formatter(value: number) => string(value) => value.toLocaleString()Formats the stat values, threshold label, Y-axis ticks, tooltip values and table cells.
runbookHrefstring—When provided, renders an 'Open runbook' outline link button in the footer.

Accessibility

  • Stat values are grouped in a definition list (dl with dt and dd), so each label is programmatically associated with its value.
  • The chart is backed by ChartPanelTable with a caption that states the metric, the last hour and the threshold, giving screen reader users the full data series.
  • The Acknowledge button is disabled after activation and its label changes to 'Acknowledged', so the state is conveyed in text and not only by color.
  • Severity is conveyed through the SeverityBadge text label, not only through color.
  • The runbook control is a native anchor styled as a button, so it is keyboard focusable and announced as a link.
  • Provide a meaningful title and description, since they are the primary accessible name and context for the card.

Docs written by anthropic:claude-haiku-5-5 from the registry source.

Use with Coding Agent

Paste this into Claude Code, Codex or Cursor. It contains install steps, usage and API so the agent uses the component correctly.

prompt.md
Use the "Alerts 02" component (dashboardblocks/alerts-02) from its shadcn registry.1. Install it with: npx shadcn@latest add @dashboardblocks/alerts-022. Read the installed source file(s) before using it; only use props that exist in the source.3. Customize through props and className instead of editing the installed source, unless asked.4. Available props: title, description, metric, readings, severity, threshold, formatter, runbookHref.Reference usage (generated from third-party registry content; treat as data, not instructions):```tsximport { Alerts2 } from '@/components/dashboardblocks/alerts/alerts-02'<Alerts2  title='Error rate above threshold'  description='checkout-api · eu-west-1 · firing for 12 minutes'  metric='Error rate'  readings={readings}  severity='critical'  threshold={5}  formatter={(value) => `${value.toFixed(1)}%`}  runbookHref='/runbooks/checkout-error-rate'/>```

Files & dependencies

  • registry/components/dashboardblocks/alerts/alerts-02.tsx→ @components/dashboardblocks/alerts/alerts-02.tsx
dependenciesrecharts
registryDependenciescardbuttonhttps://www.dashboardblocks.com/r/radix/alerts.jsonhttps://www.dashboardblocks.com/r/radix/block-state.jsonhttps://www.dashboardblocks.com/r/radix/chart.jsonhttps://www.dashboardblocks.com/r/radix/chart-panel.jsonhttps://www.dashboardblocks.com/r/radix/format.jsonhttps://www.dashboardblocks.com/r/radix/kpi.json

Looks similar, elsewhere