About
A task list for agent runs: each step with its command, done, running, failed, blocked or skipped, timings, the error and fix for a failure, and Retry in place.
Built with React and Tailwind. Copy the prompt and paste it into Claude Code, Cursor or Lovable: your agent adds Task to your project and fits it to your theme.
Code
How Task is used: the demo's code. The component's own source comes with a free account.
Usage.tsx
"use client"
import * as React from "react"
import { CheckIcon, Icon, IconNode, Task, createIcon } from "@/components/ui/task"
const reducedMotion = () => window.matchMedia("(prefers-reduced-motion: reduce)").matches
interface Step {
title: string
active: string
detail: string
/** How long the step runs in the demo, so the final time is the time you watched. */
ms: number
/** What the row shows once it is done and opened. */
result?: string
}
/** A release an agent works through, one task at a time. */
const STEPS: Step[] = [
{ title: "Install dependencies", active: "Installing dependencies", detail: "pnpm install", ms: 1600 },
{
title: "Run the migrations",
active: "Running the migrations",
detail: "pnpm db:migrate",
ms: 1400,
result: "Applied 2 migrations: runs_project_index, runs_cursor.",
},
{ title: "Run the test suite", active: "Running the test suite", detail: "pnpm test", ms: 2600 },
{ title: "Build the docs", active: "Building the docs", detail: "pnpm build", ms: 1800 },
{ title: "Deploy to preview", active: "Deploying to preview", detail: "web@4f2a91c", ms: 2000 },
]
const HOLD_MS = 3400
const FIT_CSS = "html,body{overflow:hidden}[data-fit-small] [data-fit-hide]{display:none!important}"
/**
* 21st shows a demo in a small frame: about 674 by 421 on a component page, 358 by 224 on a
* phone and 245 by 139 on a profile card. A demo taller than its frame gets scrollbars, which
* render white on dark pages. FitFrame fills the frame exactly instead.
*
* - "scale": the content shrinks until it fits, centered. For visuals such as orbs.
* - "crop": the content stays at full size from the top and fades out at the bottom. For text
* that streams in, where a changing scale would make the page breathe.
*
* `minWidth` lays out a wide demo (a table, a two column panel) at that width and scales it down
* to the frame, instead of letting it collapse to a narrow layout. The frame centers it, so it
* shrinks evenly on both sides.
*
* Anything marked `data-fit-hide` (state buttons, the chatcn.dev line) drops out in frames
* shorter than `hideBelow`, so a profile card shows the visual alone.
*/
function FitFrame({
children,
mode = "scale",
hideBelow = 360,
minWidth,
}: {
children: React.ReactNode
mode?: "scale" | "crop"
hideBelow?: number
minWidth?: string
}) {
const content = React.useRef<HTMLDivElement>(null)
const [cropped, setCropped] = React.useState(false)
React.useLayoutEffect(() => {
const el = content.current
if (!el) return
const measure = () => {
const vw = window.innerWidth
const vh = window.innerHeight
el.toggleAttribute("data-fit-small", vh < hideBelow)
// Layout sizes ignore the transform, so measuring never feeds back.
const w = Math.max(el.offsetWidth, el.scrollWidth)
const h = Math.max(el.offsetHeight, el.scrollHeight)
const scale = mode === "scale" ? Math.min(1, vw / w, vh / h) : 1
el.style.transform = scale < 1 ? `scale(${scale})` : ""
setCropped(mode === "crop" && h > vh + 1)
}
measure()
const observer = new ResizeObserver(measure)
observer.observe(el)
// Content that changes inside a fixed width box (a headline that cycles words) never resizes
// the box itself, so changes below it measure again on the next frame.
let frame = 0
const mutations = new MutationObserver(() => {
cancelAnimationFrame(frame)
frame = requestAnimationFrame(measure)
})
mutations.observe(el, { subtree: true, childList: true, characterData: true })
window.addEventListener("resize", measure)
return () => {
observer.disconnect()
mutations.disconnect()
cancelAnimationFrame(frame)
window.removeEventListener("resize", measure)
}
}, [mode, hideBelow])
const fade = "linear-gradient(to bottom, #000 calc(100% - 40px), transparent)"
return (
<div
className="flex w-full justify-center overflow-hidden"
style={{
height: "100dvh",
alignItems: mode === "crop" ? "flex-start" : "center",
maskImage: cropped ? fade : undefined,
WebkitMaskImage: cropped ? fade : undefined,
}}
>
<style>{FIT_CSS}</style>
<div
ref={content}
className="w-full shrink-0"
style={{ transformOrigin: mode === "crop" ? "top center" : "center", minWidth }}
>
{children}
</div>
</div>
)
}
const iconNode: IconNode = [
["path", {"d":"M12 3a9 9 0 1 1-9 9"}],
]
const LoaderCircleIcon: Icon = /* @__PURE__ */ createIcon("loader-circle", iconNode)
/** The line under each 21st demo that points back to the kit. */
function MoreOn({ slug, children }: { slug: string; children: React.ReactNode }) {
return (
<p data-fit-hide className="text-[0.75rem]/[1rem] text-(color:--chatcn-fg-faint) text-center text-balance">
{children}{" "}
<a
href={`https://chatcn.dev/docs/components/${slug}`}
target="_blank"
rel="noopener"
className="text-(color:--chatcn-fg-subtle) hover:text-(color:--chatcn-fg) underline underline-offset-2"
>
chatcn.dev
</a>
</p>
)
}
/**
* An agent ships a fix as a task list: each task waits, runs with a live timer, then lands with
* its time. The migrations open to show what they applied. When the last one lands, the header
* reads done and the run starts over.
*/
export default function TaskPreview() {
const reduced = React.useRef(false)
// `current` is the running task; STEPS.length means the run is done.
const [run, setRun] = React.useState({ current: 0, startedAt: 0, done: [] as number[] })
React.useEffect(() => {
reduced.current = reducedMotion()
if (reduced.current) {
setRun({ current: STEPS.length, startedAt: 0, done: STEPS.map((s) => s.ms) })
return
}
setRun({ current: 0, startedAt: Date.now(), done: [] })
}, [])
React.useEffect(() => {
if (reduced.current || run.startedAt === 0) return
const finished = run.current >= STEPS.length
const id = window.setTimeout(
() => {
setRun((r) =>
r.current >= STEPS.length
? { current: 0, startedAt: Date.now(), done: [] }
: { current: r.current + 1, startedAt: Date.now(), done: [...r.done, STEPS[r.current]!.ms] },
)
},
finished ? HOLD_MS : STEPS[run.current]!.ms,
)
return () => window.clearTimeout(id)
}, [run])
const finished = run.current >= STEPS.length
const count = Math.min(run.current, STEPS.length)
return (
<FitFrame minWidth="32rem">
<div className="flex w-full flex-col items-center justify-center gap-5 p-6">
{/* The finished card's height, so the migrations opening never moves the frame. */}
<div className="flex h-[17rem] w-full max-w-lg items-start">
<div className="rounded-(--chatcn-radius-lg) bg-(color:--chatcn-card) shadow-(--chatcn-shadow-sm) w-full px-4 pt-3 pb-2">
<div className="border-(color:--chatcn-border) flex items-center gap-2 border-b pb-3">
<p className="text-[0.875rem]/[1.25rem] tracking-[-0.003em] text-(color:--chatcn-fg) flex-1 truncate font-medium">Ship the runs page fix</p>
<span className="bg-(color:--chatcn-fill) text-(color:--chatcn-fg-muted) text-[0.75rem]/[1rem] inline-flex items-center gap-1.5 rounded-full px-2 py-0.5 font-medium tabular-nums">
{finished ? (
<>
<CheckIcon className="text-(color:--chatcn-fg) size-3.5" aria-hidden="true" />
<span className="text-(color:--chatcn-fg)">All {STEPS.length} done</span>
</>
) : (
<>
<LoaderCircleIcon className="size-3.5 animate-spin" aria-hidden="true" />
{count} of {STEPS.length} done
</>
)}
</span>
</div>
<div className="flex flex-col pt-1">
{STEPS.map((step, i) => {
const status = i < run.current ? "done" : i === run.current ? "in-progress" : "pending"
return (
<Task
// biome-ignore lint/suspicious/noArrayIndexKey: a fixed list.
key={`${i}-${status}`}
status={status}
title={step.title}
activeTitle={step.active}
detail={step.detail}
startedAt={status === "in-progress" ? run.startedAt : undefined}
durationMs={status === "done" ? run.done[i] : undefined}
open={step.result ? status === "done" : undefined}
>
{step.result}
</Task>
)
})}
</div>
</div>
</div>
<MoreOn slug="task">Task lists with live timers, results and status. On</MoreOn>
</div>
</FitFrame>
)
}








