Trace
A list of lines showing the steps an AI agent took, such as reasoning, tool calls, and sources. Lines can show a status and expand to reveal details.
View in Storybook (opens in a new tab)
Installation
import { Trace } from "@ginga-ui/core";Basic usage
Each TraceLine combines an icon and a title.
import { Trace, TraceIcon, TraceLine, TraceTitle } from "@ginga-ui/core";
import { FileText, Search } from "lucide-react";
import styles from "./trace.module.css";
export function BasicExample() {
return (
<Trace className={styles.trace}>
<TraceLine>
<TraceIcon>
<Search />
</TraceIcon>
<TraceTitle>Searched for minimumReleaseAge</TraceTitle>
</TraceLine>
<TraceLine>
<TraceIcon>
<FileText />
</TraceIcon>
<TraceTitle>Read pnpm-workspace.yaml</TraceTitle>
</TraceLine>
</Trace>
);
}Status
Specify running, error, or pending with status. Write the state in the title as well, since color alone does not convey it.
import { Trace, TraceIcon, TraceLine, TraceTitle } from "@ginga-ui/core";
import { CircleAlert, CircleCheck, CircleDashed, LoaderCircle } from "lucide-react";
import styles from "./trace.module.css";
export function StatusExample() {
return (
<Trace className={styles.trace}>
<TraceLine>
<TraceIcon>
<CircleCheck />
</TraceIcon>
<TraceTitle>Ran pnpm --version</TraceTitle>
</TraceLine>
<TraceLine status="error">
<TraceIcon>
<CircleAlert />
</TraceIcon>
<TraceTitle>Failed to run pnpm install</TraceTitle>
</TraceLine>
<TraceLine status="running">
<TraceIcon>
<LoaderCircle />
</TraceIcon>
<TraceTitle>Updating the lockfile</TraceTitle>
</TraceLine>
<TraceLine status="pending">
<TraceIcon>
<CircleDashed />
</TraceIcon>
<TraceTitle>Run the tests</TraceTitle>
</TraceLine>
</Trace>
);
}Expandable lines
Wrap a line in TraceCollapsible to show details such as command output.
import { Trace, TraceCollapsible, TraceCollapsibleContent, TraceCollapsibleTrigger, TraceDescription, TraceIcon, TraceLine, TraceTitle } from "@ginga-ui/core";
import { ChevronRight, Search, Terminal } from "lucide-react";
import styles from "./trace.module.css";
export function CollapsibleExample() {
return (
<Trace className={styles.trace}>
<TraceCollapsible defaultExpanded>
<TraceCollapsibleTrigger icon={<ChevronRight />}>
<TraceLine>
<TraceIcon>
<Terminal />
</TraceIcon>
<TraceTitle>Ran git diff --stat</TraceTitle>
<TraceDescription>+2 -1</TraceDescription>
</TraceLine>
</TraceCollapsibleTrigger>
<TraceCollapsibleContent>
package.json | 2 +- (1 file changed)
</TraceCollapsibleContent>
</TraceCollapsible>
<TraceCollapsible>
<TraceCollapsibleTrigger icon={<ChevronRight />}>
<TraceLine>
<TraceIcon>
<Search />
</TraceIcon>
<TraceTitle>Used 2 sources</TraceTitle>
</TraceLine>
</TraceCollapsibleTrigger>
<TraceCollapsibleContent>
<TraceLine>
<TraceTitle>pnpm install documentation</TraceTitle>
</TraceLine>
<TraceLine>
<TraceTitle>How lockfiles work</TraceTitle>
</TraceLine>
</TraceCollapsibleContent>
</TraceCollapsible>
</Trace>
);
}Links
Wrap a TraceLine in a link to make it navigate.
import { Trace, TraceIcon, TraceLine, TraceTitle } from "@ginga-ui/core";
import { ArrowUpRight } from "lucide-react";
import styles from "./trace.module.css";
export function LinkExample() {
return (
<Trace className={styles.trace}>
<a
href="https://pnpm.io/"
target="_blank"
rel="noreferrer"
aria-label="Read the pnpm documentation (opens in a new tab)"
>
<TraceLine>
<TraceTitle>Read the pnpm documentation</TraceTitle>
<TraceIcon>
<ArrowUpRight />
</TraceIcon>
</TraceLine>
</a>
</Trace>
);
}Props
Trace
| Name | Type | Default | Description |
|---|---|---|---|
render | (props) => ReactElement | - | Replaces the root element. Return an element that receives the given props, such as next/link. |
Also accepts the attributes of the HTML div (opens in a new tab) element.
TraceLine
| Name | Type | Default | Description |
|---|---|---|---|
status | "complete" | "running" | "error" | "pending" | - | Status of the step. It is read out to screen readers along with the line. |
statusLabel | string | - | Text read out for the status. By default, a label for the current locale is used. |
render | (props) => ReactElement | - | Replaces the root element. Return an element that receives the given props, such as next/link. |
Also accepts the attributes of the HTML span (opens in a new tab) element.
TraceIcon
| Name | Type | Default | Description |
|---|---|---|---|
render | (props) => ReactElement | - | Replaces the root element. Return an element that receives the given props, such as next/link. |
Also accepts the attributes of the HTML span (opens in a new tab) element.
TraceTitle
| Name | Type | Default | Description |
|---|---|---|---|
render | (props) => ReactElement | - | Replaces the root element. Return an element that receives the given props, such as next/link. |
Also accepts the attributes of the HTML span (opens in a new tab) element.
TraceDescription
| Name | Type | Default | Description |
|---|---|---|---|
render | (props) => ReactElement | - | Replaces the root element. Return an element that receives the given props, such as next/link. |
Also accepts the attributes of the HTML span (opens in a new tab) element.
TraceCollapsible
| Name | Type | Default | Description |
|---|---|---|---|
expanded | boolean | - | Whether the details are expanded (controlled). Use it with onExpandedChange. |
disabled | boolean | false | Disables expanding. |
Also accepts the props of React Aria's Disclosure (opens in a new tab).
TraceCollapsibleTrigger
| Name | Type | Default | Description |
|---|---|---|---|
icon | ReactNode | - | Icon shown at the end of the trigger. It rotates when expanded. |
disabled | boolean | false | Disables the trigger. |
Also accepts the props of React Aria's Button (opens in a new tab).
TraceCollapsibleContent
Accepts the props of React Aria's DisclosurePanel (opens in a new tab).