Shadcn Task Components
A collapsible step list for agent work. The title says what the agent is doing or has done, and each search, read, edit or command appears under it as the agent takes it, with running and error states, file links and timing. Composed from the Trace component, built on ui-sdk and styled with shadcn/ui theme tokens. Browse our collection of 8 Shadcn Task variants.
Basic
Streaming steps
File links
Error and retry
error: GET registry.npmjs.org/zod failed with ETIMEDOUT
Multiple tasks
Step details
- middleware.ts:14const session = await getSession(request)
- app/dashboard/layout.tsx:9const session = await getSession()
- lib/auth/session.ts:31export async function getSession(
The cookie maxAge is set in seconds but the refresh check reads it as days, so sessions end after one week instead of thirty days.
Inside a chat message
Elapsed time
Unlock premium components
Explore Shadcn Blocks
Ready-made page sections built with the same components.
Shadcn Task Component
The Shadcn Task component shows what an AI agent is working on as a collapsible list of steps. Its title says what the agent is doing while it works, such as Finding the signup flow, and what it did once it is done, such as Found the signup flow. Every search, file read, edit and command appears under the title as the agent takes it.
The examples cover a finished task that opens on click, a task whose steps stream in and that collapses itself when done, file steps that link to the file with added and removed line counts, a failed command with a Retry button, several tasks in one trace, steps with expandable output, a task inside a chat message and a long running job with elapsed time per step. Task is a composition of the kit's Trace component, built on ui-sdk and styled with shadcn/ui and Tailwind CSS.
What is the Shadcn Task Component?
A task groups the steps an agent takes toward one goal under a single line. The title is a TraceCollapsibleTrigger and the steps are TraceLine rows inside TraceCollapsibleContent. Unlike a plan, a task has no pending steps: a step is added only when the agent starts it, marked as running while it works and shown in the past tense once it is done.
Use it in coding agents, AI assistants and background jobs, wherever users want to see what the agent looked at and changed without reading a full log. For a flat list of tool calls without a grouping title, use Trace on its own.
Anatomy of the Shadcn Task
| Part | Description |
|---|---|
| Trace | The root that holds one or more tasks and adds arrow key navigation between every visible trigger and link. |
| TraceCollapsible | One task. Pass defaultOpen for a task that starts expanded, or control it with open and onOpenChange to open the running task and close it when it finishes. |
| TraceCollapsibleTrigger | The task title row. It renders a button with a chevron that rotates when the task is open and turns red when a step inside has failed. |
| TraceCollapsibleContent | The step list, indented under a border line with a height animation. Add keepMounted so the steps stay in the page while the task is closed. |
| TraceLine | One row: the task title or a step. Set status to running for a shimmer on the title or error for destructive text, and leave it unset when the step is done. |
| TraceIcon, TraceTitle and TraceDescription | A 16px icon slot, a title that truncates on narrow screens and a small muted text for counts, timings or results. |
8 Shadcn Task Variants
Each task variant listed here is previewed live at the top of this page, together with its source code and install command.
- Basic: A finished task that starts closed. Clicking the title shows the search and read steps behind it.
- Streaming steps: Steps appear one by one with a spinner on the running step. The title switches from present to past tense and the task collapses when the last step is done. A Replay button runs it again.
- File links: Read, edit and create steps wrapped in links to the file, with the path in monospace and added and removed line counts in Badges.
- Error and retry: A failed install marked with the error status and the message below it. Retry runs the step again and the task finishes in the past tense.
- Multiple tasks: Three tasks in one trace. The running task is open and each finished task closes, while users can still open any of them.
- Step details: Steps that open themselves, showing search matches with file and line, and the output of a failed test run, followed by the finding.
- Inside a chat message and elapsed time: A task in an assistant Message with the reply Bubble after it, and an indexing job that counts seconds for the task and for each step.
How to Install the Shadcn Task Component
Set up shadcn/ui in your project if you have not already, then add the Shadcn UI Kit registry to your components.json once:
{
"registries": {
"@shadcnuikit": "https://shadcnuikit.com/r/{name}.json"
}
}Then install a task variant by its name:
npx shadcn@latest add @shadcnuikit/task1The same command works with pnpm dlx, yarn dlx and bunx --bun. Each variant has a copy button for every package manager, and the code is added to your project as plain React and Tailwind CSS that you can edit freely.
How to Use the Shadcn Task Component
Render one TraceCollapsible per task, switch the title tense with the task state and add a step row for every step the agent has started.
import { FileTextIcon, SearchIcon } from "lucide-react"
import {
Trace,
TraceCollapsible,
TraceCollapsibleContent,
TraceCollapsibleTrigger,
TraceIcon,
TraceLine,
TraceTitle,
} from "@/components/ui/trace"
export function AgentTask({ done }: { done: boolean }) {
return (
<Trace>
<TraceCollapsible defaultOpen>
<TraceCollapsibleTrigger>
<TraceLine status={done ? undefined : "running"}>
<TraceTitle>{done ? "Found the route files" : "Finding the route files"}</TraceTitle>
</TraceLine>
</TraceCollapsibleTrigger>
<TraceCollapsibleContent keepMounted>
<TraceLine>
<TraceIcon>
<SearchIcon />
</TraceIcon>
<TraceTitle>Searched for createRouter</TraceTitle>
</TraceLine>
<TraceLine>
<TraceIcon>
<FileTextIcon />
</TraceIcon>
<TraceTitle>Read app/routes.ts</TraceTitle>
</TraceLine>
</TraceCollapsibleContent>
</TraceCollapsible>
</Trace>
)
}Why Use the Shadcn Task Component
- One line per goal: Grouping steps under a task title keeps long agent runs short to scan, and users open only the task they care about.
- Honest progress: Steps appear only when the agent starts them, so the list never promises work that may not happen.
- Clear states: Running steps shimmer and show a spinner, failed steps turn destructive and finished steps read in the past tense.
- No new component: Task is built from Trace parts plus Button, Badge and Spinner, so it shares the same keyboard support and styling as the rest of your agent UI.
- Theme aware: Every color comes from your theme tokens, so tasks look right in light and dark mode.
Common Task Use Cases
- Coding agents: Searches, file reads, edits and test runs grouped by goal.
- AI assistants: The work behind an answer, shown above the reply.
- Debugging: Matches and command output that explain a finding.
- Background jobs: Indexing, imports and syncs with time per step.
- Failed runs: A failed command with the error and a Retry button.
Customizing the Shadcn Task
Steps are plain children, so any row can hold a Badge, a duration in TraceDescription or a nested TraceCollapsible with output. Every part accepts className, and colors follow your theme variables, which you can create with the free Theme Generator.
Wrap a step in a link to open the file it touched. Links and buttons that contain a TraceLine get the hover and focus styles and join the arrow key navigation:
<a href="/files/components/pricing/plan-card.tsx">
<TraceLine>
<TraceIcon>
<FilePenIcon />
</TraceIcon>
<TraceTitle>Edited components/pricing/plan-card.tsx</TraceTitle>
</TraceLine>
</a>Task Accessibility and Keyboard Support
The task title is a real button with aria-expanded, so screen readers announce whether the steps are shown. The examples set aria-busy on the trace while the agent works, and step icons are hidden from assistive technology because the title already says what happened.
Under reduced motion the running shimmer, the spinners, the panel height animation and the step fade in are turned off, while the steps and titles still update.
| Key | Action |
|---|---|
| Enter or Space | Opens or closes the focused task, or follows a file link. |
| Arrow Down and Arrow Up | Move focus to the next or previous visible task or link. |
| Arrow Right | Opens a closed task, or moves into an open one. |
| Arrow Left | Closes an open task, or moves from a step back to its task. |
| Home and End | Move focus to the first or last visible item. |
Task Best Practices
- Write the title in the present tense while the task runs and switch to the past tense when it is done.
- Add a step only when the agent starts it; use a plan component for steps that are still pending.
- Keep the running task open and close finished tasks so the newest work stays in view.
- Give every streamed task a stable id so its open state survives re-renders.
- Show the error message and a way to retry next to a failed step instead of hiding it in a log.
Shadcn Task for AI Agents
Task gives an agent a clear way to show its own work: one collapsible title per goal, written in the present tense while it runs and the past tense when done, with a TraceLine for every search, file read, edit or command as it happens. It can mark the running step with a spinner, flag a failed command with the error status and a Retry button, link file steps to the file and add line counts or timings.
Install it with an AI agent
Claude Code, Cursor, Codex and other agents can install these with the shadcn CLI, for example npx shadcn@latest add @shadcnuikit/task1. With the Shadcn UI Kit MCP server, your agent can search every variant by name and add the right one for you. To give it full context, share /components/task.md, the Markdown version of this page with every variant and install command.
Example prompts
- āRender each data-task part from our agent stream as a Task built from TraceCollapsible, keyed by the part id, with the running task open and finished tasks closed.ā
- āShow the file edits from our coding agent as Task steps that link to the file, with added and removed line counts in Badges.ā
- āWhen a tool call fails, mark its Task step with status error, show the error message under it and add a Retry button that runs the tool again.ā
Customize it with AI
Ask the agent to compose Task from the parts in components/ui/trace.tsx instead of adding a new component, and to switch the title tense from the task state rather than hardcoding it. Control open and onOpenChange so a task can close itself when it finishes without fighting the user, and add keepMounted to the content. Keep a stable id per task, or the open state jumps to the wrong task while it streams.
Components Related to Task
Shadcn Task FAQ
npx shadcn@latest add @shadcnuikit/task1. With a Pro plan, the Shadcn UI Kit MCP server can also build complete sections and pages around it.Looking for something else? Browse all shadcn/ui components or ready-made UI blocks built with them.















