← Components

Communication

Trace

The steps an agent takes. Running dots pulse, success pops, errors shake; a tint fills the left edge like liquid in a tube as steps complete.

Examples and variants

Steps

Press Next step; expand the failed line.

  1. Install packages

    npm install

    , running
  2. , waiting
  3. Open a pull request

    , waiting
Example
function TraceSteps() {
  const [step, setStep] = useState(0)
  return (
    <div className="flex w-full max-w-sm flex-col gap-3">
      <Trace>
        <TraceItem status={step > 0 ? "success" : "running"} title="Install packages" description="npm install" />
        <TraceItem status={step > 1 ? "error" : step > 0 ? "running" : "pending"} title="Run tests">
          2 passed, 1 failed: button.test.tsx
        </TraceItem>
        <TraceItem status="pending" title="Open a pull request" />
      </Trace>
      <Button size="sm" variant="secondary" className="self-start" onClick={() => setStep((s) => (s >= 2 ? 0 : s + 1))}>
        Next step
      </Button>
    </div>
  )
}

Spec drawing

Measured from the live component at default density. Each code maps to the token that sets it; change the token and the drawing follows.

Install

With the CLI

The shadcn CLI only delivers files: it copies our code from the Isotopi registry into your project and installs the packages it uses. Add the foundation once, then the component.

Terminal
npx shadcn@latest add https://isotopi.com/r/minimal.json
npx shadcn@latest add https://isotopi.com/r/trace.json

By hand

No CLI needed. Add the foundation once (see Getting started), then follow these steps. They include every component this one builds on.

  1. Install the packages it uses.

    Terminal
    npm install cn lucide-react
  2. Copy this file to the same paths in your project. Imports use the @/ alias for your project root.

    • components/ui/trace.tsxtrace
      components/ui/trace.tsx
      "use client"
      
      import * as React from "react"
      import { ChevronRightIcon } from "lucide-react"
      import { cn } from "cn"
      
      /*
        Trace: the steps an agent takes (reasoning, tool calls, sources, plans).
        Each line has a status dot: running pulses, success pops, error shakes.
        A thin tint runs down the left edge as steps complete, like liquid filling
        a tube. Lines with detail expand.
      */
      type Status = "pending" | "running" | "success" | "error"
      
      function Trace({ className, children, ...props }: React.ComponentProps<"ol">) {
        const items = React.Children.toArray(children) as React.ReactElement<{ status?: Status }>[]
        const done = items.filter((item) => item.props.status === "success" || item.props.status === "error").length
        return (
          <ol
            data-slot="trace"
            className={cn("trace relative flex flex-col gap-(--trace-gap) ps-6", className)}
            style={{ "--trace-progress": items.length ? done / items.length : 0 } as React.CSSProperties}
            {...props}
          >
            <span aria-hidden className="absolute start-[calc(var(--trace-dot-size)/2+3px)] top-2 bottom-2 w-0.5 rounded-(--shape-full) bg-(--trace-tube)">
              <span className="trace-fill block w-full rounded-(--shape-full) bg-(--trace-tube-fill)" />
            </span>
            {children}
          </ol>
        )
      }
      
      function TraceItem({
        status = "pending",
        title,
        description,
        children,
        className,
      }: {
        status?: Status
        title: React.ReactNode
        description?: React.ReactNode
        /** Optional detail (output, sources); makes the line expandable. */
        children?: React.ReactNode
        className?: string
      }) {
        const [open, setOpen] = React.useState(false)
        const statusText = { pending: "waiting", running: "running", success: "done", error: "failed" }[status]
        return (
          <li data-slot="trace-item" data-status={status} className={cn("trace-item relative", className)}>
            <span aria-hidden data-status={status} className="trace-dot absolute -start-6 top-1.5 size-(--trace-dot-size) rounded-full" />
            <div className="flex items-start gap-2">
              <div className="min-w-0 flex-1">
                {children ? (
                  <button
                    type="button"
                    aria-expanded={open}
                    onClick={() => setOpen((value) => !value)}
                    className="hit-target inline-flex items-center gap-1 rounded-(--shape-sm) text-start text-sm font-medium outline-none focus-visible:shadow-(--focus-ring)"
                  >
                    {title}
                    <ChevronRightIcon aria-hidden className={cn("trace-chevron size-(--size-icon-sm) text-ink-subtle", open && "rotate-90")} />
                  </button>
                ) : (
                  <p className="text-sm font-medium">{title}</p>
                )}
                {description ? <p className="text-sm text-muted-foreground">{description}</p> : null}
                <span className="sr-only">, {statusText}</span>
              </div>
            </div>
            {children ? (
              <div className="collapsible-panel overflow-hidden" style={{ height: open ? "auto" : 0 }} hidden={!open}>
                <div className="trace-detail mt-2 rounded-(--shape-sm) bg-(--code-container) p-2 font-mono text-mono">{children}</div>
              </div>
            ) : null}
          </li>
        )
      }
      
      export { Trace, TraceItem }
      

Imports

What the examples on this page import:

Imports
import { Attachment } from "@/components/ui/attachment"
import { Avatar, AvatarFallback } from "@/components/ui/avatar"
import { Bubble, BubbleGroup, BubbleReactions } from "@/components/ui/bubble"
import { Button } from "@/components/ui/button"
import { CodeBlock } from "@/components/ui/code-block"
import { Marker } from "@/components/ui/marker"
import { Message, MessageAvatar, MessageContent, MessageFooter, MessageHeader } from "@/components/ui/message"
import { MessageScroller } from "@/components/ui/message-scroller"
import { PromptInput } from "@/components/ui/prompt-input"
import { Questionnaire } from "@/components/ui/questionnaire"
import { StreamingText } from "@/components/ui/streaming-text"
import { Trace, TraceItem } from "@/components/ui/trace"
import { VoiceInput } from "@/components/ui/voice-input"
import { tokenMs } from "@/lib/motion/token-ms"

Anatomy

  1. 1Tube · --trace-tube; fill --trace-tube-fill.
  2. 2Dot · --trace-dot-size; running / success / error colours.
  3. 3Line · Title, description, expandable detail.

Props

PropTypeDefaultDescription
TraceItem status"pending" | "running" | "success" | "error""pending"Step state.
TraceItem title, description, childrenReactNode—children makes it expandable.

Tokens

Every visual spec is a component token in styles/tokens/components.css, pointing at a semantic token. Change a token to restyle the component; themes change the semantic layer.

TokenPoints toLightDark
--trace-dot-sizevar(--space-2)8pxsame
--trace-dotvar(--stroke-color-strong)oklch(0.22 0.01 260 / 28%)oklch(1 0 0 / 20%)
--trace-dot-runningvar(--color-info)oklch(0.6 0.17 248)oklch(0.72 0.14 245)
--trace-dot-successvar(--color-success)oklch(0.52 0.14 150)oklch(0.72 0.17 150)
--trace-dot-errorvar(--color-danger)oklch(0.55 0.2 25)oklch(0.68 0.18 22)
--trace-tubevar(--surface-container)oklch(0.965 0.005 95)oklch(0.12 0 0)
--trace-tube-fillvar(--color-success)oklch(0.52 0.14 150)oklch(0.72 0.17 150)
--trace-gapvar(--space-3)12pxsame

Motion

TriggerWhat happensTokens
ProgressThe tube fills as steps finish.--duration-fill, --ease-sheet
StatusRunning pulses; success pops; error shakes.--duration-pulse, --duration-medium

Calm keeps the motion without overshoot. Still (and reduced motion) keeps a designed frame with no movement.

Accessibility

  • An ordered list; each line reads its status (“Run tests, failed”).

Usage

Do

  • Show every step an agent takes.

Don’t

  • Don't use for the agent's reply.

Code

components/ui/trace.tsx
"use client"

import * as React from "react"
import { ChevronRightIcon } from "lucide-react"
import { cn } from "cn"

/*
  Trace: the steps an agent takes (reasoning, tool calls, sources, plans).
  Each line has a status dot: running pulses, success pops, error shakes.
  A thin tint runs down the left edge as steps complete, like liquid filling
  a tube. Lines with detail expand.
*/
type Status = "pending" | "running" | "success" | "error"

function Trace({ className, children, ...props }: React.ComponentProps<"ol">) {
  const items = React.Children.toArray(children) as React.ReactElement<{ status?: Status }>[]
  const done = items.filter((item) => item.props.status === "success" || item.props.status === "error").length
  return (
    <ol
      data-slot="trace"
      className={cn("trace relative flex flex-col gap-(--trace-gap) ps-6", className)}
      style={{ "--trace-progress": items.length ? done / items.length : 0 } as React.CSSProperties}
      {...props}
    >
      <span aria-hidden className="absolute start-[calc(var(--trace-dot-size)/2+3px)] top-2 bottom-2 w-0.5 rounded-(--shape-full) bg-(--trace-tube)">
        <span className="trace-fill block w-full rounded-(--shape-full) bg-(--trace-tube-fill)" />
      </span>
      {children}
    </ol>
  )
}

function TraceItem({
  status = "pending",
  title,
  description,
  children,
  className,
}: {
  status?: Status
  title: React.ReactNode
  description?: React.ReactNode
  /** Optional detail (output, sources); makes the line expandable. */
  children?: React.ReactNode
  className?: string
}) {
  const [open, setOpen] = React.useState(false)
  const statusText = { pending: "waiting", running: "running", success: "done", error: "failed" }[status]
  return (
    <li data-slot="trace-item" data-status={status} className={cn("trace-item relative", className)}>
      <span aria-hidden data-status={status} className="trace-dot absolute -start-6 top-1.5 size-(--trace-dot-size) rounded-full" />
      <div className="flex items-start gap-2">
        <div className="min-w-0 flex-1">
          {children ? (
            <button
              type="button"
              aria-expanded={open}
              onClick={() => setOpen((value) => !value)}
              className="hit-target inline-flex items-center gap-1 rounded-(--shape-sm) text-start text-sm font-medium outline-none focus-visible:shadow-(--focus-ring)"
            >
              {title}
              <ChevronRightIcon aria-hidden className={cn("trace-chevron size-(--size-icon-sm) text-ink-subtle", open && "rotate-90")} />
            </button>
          ) : (
            <p className="text-sm font-medium">{title}</p>
          )}
          {description ? <p className="text-sm text-muted-foreground">{description}</p> : null}
          <span className="sr-only">, {statusText}</span>
        </div>
      </div>
      {children ? (
        <div className="collapsible-panel overflow-hidden" style={{ height: open ? "auto" : 0 }} hidden={!open}>
          <div className="trace-detail mt-2 rounded-(--shape-sm) bg-(--code-container) p-2 font-mono text-mono">{children}</div>
        </div>
      ) : null}
    </li>
  )
}

export { Trace, TraceItem }