# Check runs

> A list of automated checks such as tests, lint and build, each with its state, command, last run and Output and Run actions.

- Kind: ui · Category: Feedback · Interactivity: none
- Install: `npx shadcn@latest add @haze/check-runs`
- File: `src/components/haze/ui/check-runs.astro`
- npm dependencies: @lucide/astro
- Registry dependencies: @haze/button, @haze/utils
- Docs page: https://hazeui.com/ui/check-runs

## Use when
- A project dashboard shows whether its tests, lint, typecheck and build pass
- A deploy screen lists the checks that gate a release

## Avoid when
- The steps run in a fixed order a person walks through. Use stepper.
- Only one overall state matters. Use status or alert.

## Alternatives
- [stepper](https://hazeui.com/ui/stepper.md)
- [status](https://hazeui.com/ui/status.md)
- [uptime-tracker](https://hazeui.com/ui/uptime-tracker.md)

## Props

| Name | Type | Default | Required | Description |
|---|---|---|---|---|
| title | `string` | "Checks" | no | Visible title; also names the section. |
| checks | `{ name: string; command?: string; state: "passed" \| "failed" \| "running" \| "cancelled" \| "never"; detail?: string; outputHref?: string; runHref?: string }[]` |  | no | Checks in display order. |
| stateLabels | `Partial<Record<State, string>>` |  | no | Replaces the words for each state, for translation. |
| runLabel | `string` | "Run" | no | Label of the button that starts a check. |
| outputLabel | `string` | "Output" | no | Label of the link to a check's output. |
| headingLevel | `2 \| 3 \| 4` | 3 | no | Level of the list's title. |
| class | `string` |  | no | Additional classes on the panel. |

## Accessibility
- Every state is written out next to its icon, so passed and failed never rely on green and red alone.
- The Output and Run buttons name the check they act on, such as "Run Typecheck".
- Key Tab: Move through the Output and Run actions.

## Agent prompts

### Install and use

Install the Haze UI component "Check runs" with `npx shadcn@latest add @haze/check-runs`. If components.json has no "@haze" registry yet, add "registries": { "@haze": "https://hazeui.com/r/{name}.json" }. If src/styles/haze.css does not exist yet, run `npx shadcn@latest add @haze/theme` once and import it from the global stylesheet after Tailwind. The CLI stops at an overwrite question when a Haze file already exists and differs, even with --yes, and then installs nothing after it: read its output. If the user has not edited their Haze files, re-run with --overwrite to take the registry versions; if they have, ask them before overwriting. Then import CheckRuns from "@/components/haze/ui/check-runs.astro" (or the relative path) and render it where it fits the page. Keep Haze token classes (bg-background, text-muted-foreground, border-border...) and never hardcode colors. Docs: https://hazeui.com/ui/check-runs.md

### Customize with real content

Adapt the Haze check-runs ui for our product. Replace the demo values of these props with our real content: title, checks, stateLabels, runLabel, outputLabel, headingLevel, class. Keep the layout, the heading level rules and these accessibility details: Every state is written out next to its icon, so passed and failed never rely on green and red alone. The Output and Run buttons name the check they act on, such as "Run Typecheck". Do not add raw color classes; use the Haze tokens.

### Choose the right block

Before using check-runs, check it fits: use it when a project dashboard shows whether its tests, lint, typecheck and build pass; a deploy screen lists the checks that gate a release. Avoid it when the steps run in a fixed order a person walks through. use stepper.; only one overall state matters. use status or alert.. Alternatives: @haze/stepper, @haze/status, @haze/uptime-tracker.

## Example requests that should lead here
- Add a checks panel listing tests, lint, typecheck and build with pass or fail, duration and a Run button.

## Source

```astro
---
import { CircleCheck, CircleDashed, CircleSlash, CircleX, LoaderCircle } from "@lucide/astro";
import { cn } from "../../../lib/haze/utils";
import Button from "./button.astro";

type State = "passed" | "failed" | "running" | "cancelled" | "never";

interface Check {
  name: string;
  /** The command that runs the check, shown in monospace. */
  command?: string;
  state: State;
  /** When it last ran and how long it took, as it should read: "2 min ago · 14 s". */
  detail?: string;
  /** Link to the check's output. */
  outputHref?: string;
  /** Link or form target that starts the check again. */
  runHref?: string;
}

interface Props {
  /** Visible title of the list. */
  title?: string;
  checks?: Check[];
  /** Overrides the words used for each state, for translation. */
  stateLabels?: Partial<Record<State, string>>;
  runLabel?: string;
  outputLabel?: string;
  headingLevel?: 2 | 3 | 4;
  class?: string;
}

const {
  title = "Checks",
  checks = [
    { name: "Unit tests", command: "pnpm test", state: "passed", detail: "4 min ago · 18 s", outputHref: "#tests", runHref: "#run-tests" },
    { name: "Lint", command: "pnpm lint", state: "passed", detail: "4 min ago · 6 s", outputHref: "#lint", runHref: "#run-lint" },
    { name: "Typecheck", command: "pnpm typecheck", state: "failed", detail: "4 min ago · 11 s · exit code 2", outputHref: "#types", runHref: "#run-types" },
    { name: "Build", command: "pnpm build", state: "running", detail: "Started 20 s ago", outputHref: "#build" },
    { name: "End-to-end", command: "pnpm test:e2e", state: "never", runHref: "#run-e2e" },
  ],
  stateLabels = {},
  runLabel = "Run",
  outputLabel = "Output",
  headingLevel = 3,
  class: className,
} = Astro.props;

const H = `h${headingLevel}` as "h3";
const labels: Record<State, string> = { passed: "Passed", failed: "Failed", running: "Running", cancelled: "Cancelled", never: "Never run", ...stateLabels };
const tones: Record<State, string> = {
  passed: "text-success",
  failed: "text-destructive",
  running: "text-brand",
  cancelled: "text-muted-foreground",
  never: "text-muted-foreground",
};
const icons = { passed: CircleCheck, failed: CircleX, running: LoaderCircle, cancelled: CircleSlash, never: CircleDashed };
const ran = checks.filter((c) => c.state === "passed" || c.state === "failed");
const passed = ran.filter((c) => c.state === "passed").length;
const failed = ran.length - passed;
---

<section aria-label={title} class={cn("overflow-hidden rounded-xl border border-border bg-card", className)}>
  <div class="flex flex-wrap items-baseline justify-between gap-x-3 gap-y-1 border-b border-border px-4 py-3">
    <H class="text-[0.9375rem]/5 font-medium tracking-[-0.01em] text-foreground">{title}</H>
    <p class="text-[0.8125rem]/5 text-muted-foreground tabular-nums">
      {passed} passed{failed > 0 && <span class="text-destructive">, {failed} failed</span>}
    </p>
  </div>
  <ul role="list" class="divide-y divide-border">
    {
      checks.map((check) => {
        const Icon = icons[check.state];
        return (
          <li class="flex flex-wrap items-center gap-x-3 gap-y-2 px-4 py-3">
            <Icon aria-hidden="true" class={cn("size-4 shrink-0", tones[check.state], check.state === "running" && "animate-spin")} />
            <div class="min-w-0 flex-1">
              <p class="flex flex-wrap items-baseline gap-x-2 text-[0.8125rem]/5">
                <span class="font-medium text-foreground">{check.name}</span>
                <span class={cn("text-[0.8125rem]/5 font-medium", tones[check.state])}>{labels[check.state]}</span>
              </p>
              {(check.command || check.detail) && (
                <p class="mt-0.5 flex flex-wrap gap-x-2 text-[0.8125rem]/5 text-muted-foreground">
                  {check.command && <code class="font-mono text-xs/5">{check.command}</code>}
                  {check.detail && <span class="tabular-nums">{check.detail}</span>}
                </p>
              )}
            </div>
            {(check.outputHref || (check.runHref && check.state !== "running")) && (
              <div class="flex shrink-0 gap-1.5 max-sm:w-full max-sm:pl-7 sm:grid sm:grid-cols-[auto_minmax(3.25rem,auto)] sm:justify-items-end">
                {!check.outputHref && <span aria-hidden="true" class="max-sm:hidden"></span>}
                {check.outputHref && (
                  <Button href={check.outputHref} variant="ghost" size="sm" aria-label={`${outputLabel}: ${check.name}`}>
                    {outputLabel}
                  </Button>
                )}
                {check.runHref && check.state !== "running" && (
                  <Button href={check.runHref} variant="secondary" size="sm" aria-label={`${runLabel} ${check.name}`}>
                    {runLabel}
                  </Button>
                )}
                {!(check.runHref && check.state !== "running") && <span aria-hidden="true" class="max-sm:hidden"></span>}
              </div>
            )}
          </li>
        );
      })
    }
  </ul>
</section>
```
