Trace
Shows one step of work an agent did, is doing or will do, as a single line that can expand to the detail.
sheet: Steel
rows: 312
updated: 2026-11-24Installation
pnpm dlx shadcn@latest add @silkware/traceTo copy the component by hand, install its dependencies:
pnpm add react-aria-components cn lucide-reactTrace builds on the Collapsible, so install it too:
pnpm dlx shadcn@latest add @silkware/collapsibleThen copy the source into components/ui/trace.tsx:
"use client"
import * as React from "react"import { cn } from "cn"import { Button as ButtonPrimitive, type ButtonProps,} from "react-aria-components"
import { Collapsible, CollapsibleContent,} from "@/components/ui/collapsible"import { ChevronRightIcon } from "lucide-react"
function Trace({ className, ...props }: React.ComponentProps<"div">) { return ( <div data-slot="trace" className={cn( "flex w-full min-w-0 flex-col gap-2 *:has-[>[data-slot=trace-line]]:flex *:has-[>[data-slot=trace-line]]:w-fit *:has-[>[data-slot=trace-line]]:max-w-full *:has-[>[data-slot=trace-line]]:min-w-0 *:has-[>[data-slot=trace-line]]:rounded-md *:has-[>[data-slot=trace-line]]:text-left *:has-[>[data-slot=trace-line]]:outline-none *:has-[>[data-slot=trace-line]]:focus-visible:ring-3 *:has-[>[data-slot=trace-line]]:focus-visible:ring-ring/50", className )} {...props} /> )}
function TraceLine({ className, status, ...props}: React.ComponentProps<"span"> & { status?: "running" | "error" | "pending"}) { return ( <span data-slot="trace-line" data-status={status} className={cn( "flex w-fit max-w-full min-w-0 items-center gap-2 text-sm text-muted-foreground transition-colors in-[a,button]:cursor-pointer in-[a:hover,button:hover]:text-foreground data-[status=error]:text-destructive data-[status=error]:in-[a:hover,button:hover]:text-destructive data-[status=pending]:*:data-[slot=trace-icon]:opacity-60 data-[status=running]:*:data-[slot=trace-title]:shimmer", className )} {...props} /> )}
function TraceIcon({ className, ...props }: React.ComponentProps<"span">) { return ( <span data-slot="trace-icon" aria-hidden="true" className={cn( "flex size-4 shrink-0 items-center justify-center [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 [[data-slot=trace-title]~&]:-ml-1", className )} {...props} /> )}
function TraceTitle({ className, ...props }: React.ComponentProps<"span">) { return ( <span data-slot="trace-title" className={cn("min-w-0 truncate motion-reduce:shimmer-none", className)} {...props} /> )}
function TraceDescription({ className, ...props}: React.ComponentProps<"span">) { return ( <span data-slot="trace-description" className={cn( "shrink-0 text-muted-foreground tabular-nums", className )} {...props} /> )}
function TraceCollapsible({ className, ...props}: Omit<React.ComponentProps<typeof Collapsible>, "isExpanded" | "className"> & ( | { isExpanded?: undefined } | { isExpanded: boolean onExpandedChange: NonNullable< React.ComponentProps<typeof Collapsible>["onExpandedChange"] > } ) & { className?: string }) { return ( <Collapsible data-slot="trace-collapsible" className={cn("flex w-full min-w-0 flex-col", className)} {...props} /> )}
function TraceCollapsibleTrigger({ className, children, ...props}: Omit<ButtonProps, "className" | "children" | "slot"> & { className?: string children?: React.ReactNode}) { return ( <ButtonPrimitive slot="trigger" {...props} data-slot="trace-collapsible-trigger" className={cn( "group/trace-collapsible-trigger flex w-fit max-w-full min-w-0 cursor-pointer items-center gap-1 rounded-md text-left text-muted-foreground transition-colors outline-none hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/50 has-[[data-status=error]]:text-destructive", className )} > {children} <TraceIcon className="transition-transform group-aria-expanded/trace-collapsible-trigger:rotate-90"> <ChevronRightIcon /> </TraceIcon> </ButtonPrimitive> )}
function TraceCollapsibleContent({ className, children, ...props}: Omit< React.ComponentProps<typeof CollapsibleContent>, "className" | "children"> & { className?: string children?: React.ReactNode}) { return ( <CollapsibleContent data-slot="trace-collapsible-content" className="min-w-0 overflow-clip" {...props} > <div data-slot="trace-collapsible-content-inner" className={cn( "mt-2 mb-1 ml-[calc(--spacing(2)-1px)] min-w-0 border-l pr-1 pl-4 leading-relaxed wrap-break-word text-muted-foreground", className )} > {children} </div> </CollapsibleContent> )}
export { Trace, TraceLine, TraceIcon, TraceTitle, TraceDescription, TraceCollapsible, TraceCollapsibleTrigger, TraceCollapsibleContent,}Usage
import { Trace, TraceCollapsible, TraceCollapsibleContent, TraceCollapsibleTrigger, TraceDescription, TraceIcon, TraceLine, TraceTitle,} from "@/components/ui/trace"<Trace> <TraceCollapsible> <TraceCollapsibleTrigger> <TraceLine> <TraceIcon> <TableIcon /> </TraceIcon> <TraceTitle>Read the 2026 price list</TraceTitle> </TraceLine> </TraceCollapsibleTrigger> <TraceCollapsibleContent>312 rows, last updated 2026-11-24.</TraceCollapsibleContent> </TraceCollapsible></Trace>TraceLine is only the line: an icon and a title in a span. It does nothing on its own. To make it do something, wrap it in the thing that does it: TraceCollapsibleTrigger to expand, an a to link, a dialog trigger to open a dialog. The patterns that compose traces into whole turns are Reasoning, Tool, Chain of Thought and Task.
Examples
Line
A line on its own, for a step with nothing more to show. It reads as plain text and is not a tab stop.
Running
status="running" shimmers the title. Write the title in the present tense and put a spinning icon in TraceIcon: the component does not draw one for you.
Error
status="error" turns the line crimson. Say in the title that it failed, so the state is not carried by colour.
Pending
status="pending" dims the icon of the line and keeps the text readable, for a step that has not started, such as the next step of a plan. Write it as an instruction.
All states
A finished step has no status. Together, the four read as a short history: done, failed, running and waiting.
Description
TraceDescription puts a count, a duration or a diff stat after the title. It does not truncate, so keep it short.
Collapsible
Wrap the line in TraceCollapsibleTrigger and put the detail in TraceCollapsibleContent. The trigger adds a chevron after the line. A Code Block with size="sm" suits output.
Open state
A row starts closed. Use defaultExpanded to start it open, or isExpanded with onExpandedChange to control it, for example from a button elsewhere.
Link
Wrap the line in an a to open another page. When the link opens a new tab, add the arrow icon and a visually hidden "(opens in a new tab)" in the title.
Nested
A summary row can expand into step rows, and a step can expand into its output. Use it for a long piece of work that the reader mostly wants as one line.
Accessibility
| Key | Action |
|---|---|
| Tab | Moves focus to the next trigger or link. A plain line is skipped. |
| Enter | Expands or collapses the focused row, or follows the focused link. |
| Space | Expands or collapses the focused row. |
React Aria provides:
- A
buttonforTraceCollapsibleTriggerwitharia-expanded, and a panel that is linked to it and hidden from assistive technology while collapsed. It comes from the React AriaDisclosure. - The keyboard behaviour above, and a focus ring for keyboard focus only.
- A panel height that animates open and closed, and stops animating when reduced motion is requested.
The component provides:
aria-hiddenonTraceIcon, so the title is the only text read.- Truncation of a long title on one line.
- A shimmer on a running title that stops for readers who prefer reduced motion.
You provide:
- A title that is a sentence about what happened: "Read the 2026 price list", not "price-list.xlsx".
- The state in the title. Colour, motion and the icon are cues only: write "Comparing the two price lists" while it runs and "Failed to send order 4417" when it fails.
- "(opens in a new tab)", visually hidden, in the title of a link that opens one.
- A live region around a trace that grows while the agent works. Inside a Message Scroller each line is announced once when it is added.
- Contrast for what you place in the panel. The panel mutes its text, so a block with its own background, such as a Code Block, should set its own text colour.
Guidelines
When to use
- To show the steps an agent took on the way to an answer: what it searched, read, ran and changed.
- To show a plan as a list of steps with a state each.
- To let the reader open the detail of one step, such as the output of a command, without leaving the conversation.
When not to use
- For the answer or anything the person must read. Use a Message with a Bubble.
- For a status that does not belong to a step, such as a date or "Worked for 42 seconds". Use a Marker.
- For a failure the person must act on. Use an Alert or a Bubble with the destructive variant.
- For a section of a page that opens and closes. Use an Accordion or a Collapsible.
- To measure how far a task has come. Use Progress.
Content
- Start with a verb in the tense of the state: "Searching open orders" while it runs, "Searched open orders" when done, "Failed to send order 4417" on error, "Send order 4417 to Lamivo Metalli" while pending.
- Name the object. A step that only says "Ran a tool" tells the reader nothing.
- Keep the title to one sentence on one line. Put numbers and times in
TraceDescription. - Use sentence case, with no full stop and no exclamation mark.
- Show detail in the panel, not in the title.
State
Trace keeps its steps quiet and uses no green or amber. A done step has no status and the same grey as the others; a failed one is crimson; a running one shimmers; a pending one has a dimmed icon. The only status it colours is an error, which is already destructive. Never rely on colour alone: say the outcome in the title or the description.
Say in the title that the step failed. The crimson line only supports it.
Don’t mark a failure with the error status and a title that reads like an instruction. A reader who does not see the colour cannot tell.
Wrap a line in a trigger when it has detail to open.
Don’t make a line look clickable with classes. A span has no role or keyboard behaviour, so nothing happens.
API reference
Trace
Renders a <div>, a column of rows. It also styles any trigger or link that wraps a TraceLine.
| Prop | Type | Default | Description |
|---|---|---|---|
className? | string | None | Classes merged after the layout classes. |
TraceLine
Renders a <span> with an icon and a title. It is not a button and not a tab stop.
| Prop | Type | Default | Description |
|---|---|---|---|
status? | "running" | "error" | "pending" | None | The state of the step. running shimmers the title, error uses the destructive colour, pending dims the icon. Leave it out for a finished step. |
className? | string | None | Classes merged after the line classes. |
TraceIcon
Renders a <span> of 16px for an icon. It is hidden from assistive technology. Placed before the title it names the step; placed after it, it is an indicator such as a chevron or an arrow.
| Prop | Type | Default | Description |
|---|---|---|---|
className? | string | None | Classes merged after the icon classes. |
TraceTitle
Renders a <span> with one sentence. It truncates.
| Prop | Type | Default | Description |
|---|---|---|---|
className? | string | None | Classes merged after the title classes. |
TraceDescription
Renders a <span> with secondary text in a lighter grey, in tabular numerals. It does not truncate.
| Prop | Type | Default | Description |
|---|---|---|---|
className? | string | None | Classes merged after the description classes. |
TraceCollapsible
Renders a React Aria Disclosure as a column. It accepts the props of Collapsible except that className must be a string. isExpanded must be paired with onExpandedChange.
| Prop | Type | Default | Description |
|---|---|---|---|
defaultExpanded? | boolean | false | Whether the row starts open. |
isExpanded? | boolean | None | The controlled open state. Pass it with onExpandedChange. |
onExpandedChange? | (isExpanded: boolean) => void | None | Called when the row opens or closes. |
isDisabled? | boolean | false | Stops the row from opening or closing. |
className? | string | None | Classes merged after the layout classes. |
TraceCollapsibleTrigger
Renders the React Aria Button that opens and closes the row, with the trigger slot of the disclosure. Put a TraceLine inside it. It adds a chevron after the line that turns when the row is open.
| Prop | Type | Default | Description |
|---|---|---|---|
children? | ReactNode | None | A TraceLine. |
className? | string | None | Classes merged after the trigger classes. |
TraceCollapsibleContent
Renders the disclosure panel. The children sit in a block with a left border and muted text.
| Prop | Type | Default | Description |
|---|---|---|---|
children? | ReactNode | None | The detail of the step. |
className? | string | None | Classes merged onto the inner block, not the panel. |