# Plan

> An agent’s checklist that ticks itself off: pending, in progress, done, skipped or failed.

Shows what the agent intends to do and how far it has got. Each task’s mark changes in place: the ring becomes a spinner, the spinner blurs into a check that draws itself, and a strike-through draws across the label as it fades back. A hairline under the header fills as work completes and the count rolls. When everything is settled "done" slides in beside "5 of 5" and the plan folds into that line; if something failed the reason folds open and it stays open.

## Install

```bash
npx shadcn@latest add https://hairlineui.com/r/plan.json
```

Needs React 19, Tailwind CSS v4 and shadcn/ui theme variables (any style, light and dark). Icons from lucide-react.

- npm: `lucide-react`
- Hairline UI components it needs (the CLI installs them too): `number-roll`
- Docs and live preview: https://hairlineui.com/ui/plan
- Registry item (source): https://hairlineui.com/r/plan.json

## Usage

```tsx
import { Plan } from "@/components/plan";

<Plan
  tasks={[
    { label: "Pull last month’s sales", status: "done" },
    { label: "Compare flavors by margin", status: "running" },
    { label: "Draft the weekend special", status: "pending" },
  ]}
/>
```

## With the AI SDK

```tsx
// Server (inside createUIMessageStream): stream the plan as a data part.
// Writing the same id again updates it in place on the client.
writer.write({ type: "data-plan", id: "plan", data: { tasks } });

// Client
import type { UIMessage } from "ai";
import { Plan, type PlanTask } from "@/components/plan";

function MessagePlan({ message }: { message: UIMessage }) {
  const part = message.parts.find((p) => p.type === "data-plan");
  if (!part) return null;
  return <Plan tasks={(part.data as { tasks: PlanTask[] }).tasks} />;
}
```

## Props

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `tasks` | `{ id?; label; detail?; status }[]` | – | The checklist. Status is "pending" \| "running" \| "done" \| "skipped" \| "failed". |
| `title` | `string` | `"Plan"` | Header label. |
| `collapseWhenDone` | `boolean` | `true` | Fold into the summary once every task is settled. |
| `open / defaultOpen / onOpenChange` | `boolean / boolean / (open) => void` | `true` | Control it yourself; any click also stops the automatic folding. |

## States

- **pending**: An empty ring; not started.
- **running**: The ring blurs into a spinner and the label brightens; the task being worked on.
- **done**: The spinner blurs out as a filled check draws itself (420ms); a strike-through draws across the label left to right (520ms) as it fades back. The count rolls.
- **skipped**: A dash; no longer needed.
- **failed**: A red mark swaps in and the reason folds open underneath; the plan stays open.
- **settled**: Every task finished: "done" slides in after "5 of 5" and the list folds away 1.2s later.

## What it handles

This shows what an agent intends to do and how far it has got, so people can follow along, and see why a step failed.

- **Five statuses**: Pending, running, done, skipped and failed, each with its own mark.
- **Marks that change in place**: The ring becomes a spinner, the spinner blurs into a drawn check, and a strike draws across the label.
- **A progress line**: A hairline under the header fills as work completes, and the count (“3 of 5”) rolls.
- **Failures stay open**: A failed task shows its reason and keeps the plan open.
- **It folds when settled**: When every task is settled, “done” slides in and the plan folds into one line. It never folds after the user opened or closed it.
- **Readable by screen readers**: It is an ordered list, each task carries its status as text, and progress is announced politely.

## Replaces

a to-do list, status icons, a progress count, a collapsing summary, a failure message

## Where it fits

- **AI agent chats**: Show the steps the agent intends to take before and while it works.
- **Coding agents**: List the changes to make and tick them off as they land.
- **Workflow and automation runs**: Show which steps have run, which are running and which failed.
- **Setup and migration tools**: Give a long job a visible list of its steps.

## Notes

- It’s an ordered list; each task carries its status as text for screen readers, and the progress count is announced politely.
- The plan never folds itself away after the user has opened or closed it.
- Installs Number roll. With reduced motion the spinner, rolls, strikes and folds stop; states still read clearly.

License: MIT (https://hairlineui.com/license#components)
