Checklist
Slant / Feedback
Checks that pass, fail or warn, each with its reason, a next step and evidence.
Demo
Usage
import { Button, Checklist } from '@tuttn/slant'
// One list under a count ("1 passed, 1 failed").
<Checklist label="Release checks" items={[
{ id: 'tests', label: 'Tests pass', status: 'pass', evidence: { href: '/runs/42', label: 'Run 42' } },
{ id: 'budget', label: 'Entry JS under budget', status: 'fail', reason: '108 KB of 107 KB',
next: 'Lazy-load CodeBlock in the docs', action: <Button size="sm" onClick={rerun}>Re-run</Button> },
]} />
// Groups, each under its heading with its own count. live: the summary is a
// polite status region while checks still run, and pending checks spin.
<Checklist groups={[
{ label: 'Content', items: contentChecks },
{ label: 'SEO', items: seoChecks },
]} live headingLevel={4} />
// No count at the top.
<Checklist items={checks} summary={false} />Props
| Prop | Type | Default | Description |
|---|---|---|---|
items | readonly ChecklistItem[] | — | The checks, in one list. Pass this or `groups`. |
groups | readonly ChecklistGroup[] | — | The checks in groups, each under its heading with its own count. Pass this or `items`. |
label | string | — | Names the checklist: the root becomes a `group` with this name. |
summary | boolean | true | Shows the count over every check at the top: `messages.checklistSummary`, "3 passed, 1 failed, 2 warnings". |
live | boolean | false | For checks still running: the summary becomes a polite status region, so its count is read as checks finish, and pending checks show a Spinner. |
headingLevel | 2 | 3 | 4 | 5 | 6 | 3 | The level of the groups' headings, to fit the page's outline. |
ChecklistItem | { id: string; label: ReactNode; status: ChecklistStatus; reason?: ReactNode; next?: ReactNode; evidence?: { href: string; label?: ReactNode }; action?: ReactNode } | — | One check: what is checked, how it came out, why, what to do next, a link to its evidence (labelled `messages.evidence` by default) and a control at the row’s end. |
ChecklistGroup | { id?: string; label: ReactNode; items: readonly ChecklistItem[] } | — | A heading and its checks. `id` is the React key; a string label serves when it is left out. |
ChecklistStatus | 'pass' | 'fail' | 'warn' | 'pending' | 'skipped' | — | How a check came out; read after its label as `messages.checkStatus(status)` and rendered as the row’s `data-status`. |
…rest | HTMLAttributes<HTMLDivElement> | — | className, style, the ref and other attributes go on the root. An aria-label or aria-labelledby of yours names it as `label` does. |
Keyboard
| Tab | moves through the evidence links and the actions; the checks themselves take no focus |
Accessibility
- With
label, the root is agroupwith that name. Each list is a<ul>; in groups, each list is named by its group’s heading, which sits atheadingLevel(3 by default) in the page’s outline. - Each mark is decorative. The status is read after the label from hidden text (“Entry JS under budget, Failed”, from
messages.checkStatus), so it never rests on colour alone. - The evidence links are described by their check’s label, so several “Evidence” links still say which check each belongs to.
- The summary (
messages.checklistSummary, “3 passed, 1 failed, 2 warnings”) counts every check. Withlive, it is a politestatusregion, so the count is read as checks finish, without each row being announced. - The tones colour only the marks. Every line of text is in the text or muted colour, which keep 4.5:1 in every theme.
Checklist, Stepper or AgentPlan
A checklist has no order: each check stands on its own and can pass, fail or warn in any combination, like a release gate, an SEO audit or a preflight. When the items are steps taken one after another, use a Stepper, or an AgentPlan for an agent’s plan.
Writing checks
Name the check by what passing means (“Tests pass”, “Entry JS under budget”), so a pass reads as good news and a fail says what is wrong. Put the numbers in reason and the fix in next, which shows after a “Next step:” lead-in from messages.nextStep. A skipped check’s label is muted; say why in its reason.