suiss/ui · Component
Trace
Rows for the steps an agent takes: reasoning, tool calls, sources, plans and file edits.
Trace is an open-source component from suiss/ui for React, React Native, SwiftUI and Jetpack Compose. The @esuiss/ui CLI copies its source into your project, so you own the code.
A Trace is a list of TraceLine rows. Each row has a TraceIcon, a TraceTitle, and an optional TraceDescription and status. A row can expand to show more detail, link to a page, or open a dialog or sheet.
Every row has the same shape, so reasoning, tool calls, sources and plans built from Trace look and behave the same. Use Trace for the steps an agent takes, such as calling a tool, running a subagent or editing a file. Use Message for its reply and Marker for notes and dividers between turns.
Installation
Works in any project with a components.json. See Installation for the one-line registry setup. Or use the suiss/ui CLI:
- Install the following dependencies and add the
cnhelper:
-
Add the pieces it builds on: Collapsible.
-
Copy and paste the following code into your project.
- Update the import paths to match your project setup.
Usage
Composition
Use the following composition to build a Trace:
Examples
Static
A TraceLine on its own, for a step with no detail to show. It reads as plain text.
Status
Set status on TraceLine to running, error or pending. Leave it unset for finished work, and say the state in the title too: "Running pnpm build", "Failed to run pnpm lint", "Run pnpm test".
Description
Use TraceDescription for secondary text such as a diff stat, a duration or a count, after the title. It does not truncate.
Collapsible
Wrap the row in a TraceCollapsible to show more detail, here the command output. Put the TraceLine inside TraceCollapsibleTrigger and the detail in TraceCollapsibleContent.
Controlled
Opens and closes a row from outside. To open a row while it streams and still let the reader close it, pass the reader's choice and fall back to the running state.
Link
Wraps the TraceLine in an anchor. For a new tab, use an arrow icon and add "(opens in a new tab)" to the title with sr-only.
Dialog
Wraps the TraceLine in a DialogTrigger. The dialog owns its open state, Escape and focus return.
Sheet
The same shape as the dialog, with the TraceLine in a SheetTrigger.
Group
Rows next to each other in one Trace, which also styles any trigger or link that wraps a TraceLine.
Sources
A collapsible row whose detail is a Trace of link rows.
Steps
A summary row with step rows inside. The parent's status and title come from its children.
Commit
A row for each changed file, with the line counts in the description. Each file opens its diff in a sheet.
Whole turn
Three levels: the turn, a summary and the rows. Text between steps sits between two Trace lists.
Reasoning
A thinking row that expands into the reasoning text.
Tool calls
Tool calls with their input and output, including a failed call.
Accessibility
- Trace adds no roles of its own. Each row gets its semantics from the element that wraps it.
- A
TraceLineon its own is read as text and is not a tab stop. - Inside
TraceCollapsibleTriggerthe row is a button witharia-expanded. Inside a link or a dialog or sheet trigger, it takes that element's keyboard and focus behavior. TraceIconis hidden from assistive tech, soTraceTitleis the accessible name. Write it as a sentence that says what happened, such as "Edited trace.tsx", not just "trace.tsx".- Status is shown with color and motion, so put it in the title too.
- The running shimmer stops when the reader prefers reduced motion.
API Reference
Trace
A list of rows. It also styles any trigger or link that wraps a TraceLine.
Also accepts the props of React.ComponentProps<"div">.
TraceLine
One row: an icon and a title. It is a span, so it is not a button or a tab stop.
| Prop | Type | Default |
|---|---|---|
status | "running" | "error" | "pending" | — |
Also accepts the props of React.ComponentProps<"span">.
status is the state of the work the row reports: running shimmers the title, error turns it destructive and pending mutes it. TraceLine is always the row. To make a row do something, wrap it in that thing's trigger: a link, a DialogTrigger, a SheetTrigger, a drawer or a popover.
TraceIcon
A decorative icon slot, hidden from assistive tech. Before the title it names the action; after it, it is the indicator.
Also accepts the props of React.ComponentProps<"span">.
TraceTitle
One sentence on one line. It truncates, and shimmers while the row is running.
Also accepts the props of React.ComponentProps<"span">.
TraceDescription
Secondary text after the title, such as a count or a duration. It does not truncate.
Also accepts the props of React.ComponentProps<"span">.
TraceCollapsible
A row that expands.
| Prop | Type | Default |
|---|---|---|
open | boolean | — |
defaultOpen | boolean | false |
onOpenChange | (open: boolean) => void | — |
| Prop | Type | Default |
|---|---|---|
isExpanded | boolean | — |
defaultExpanded | boolean | false |
onExpandedChange | (isExpanded: boolean) => void | — |
Also accepts the props of Collapsible.
Also accepts the props of Collapsible, except asChild.
Rows start closed. Set defaultOpen to start open, or pass open with onOpenChange to control it.
Rows start closed. Set defaultExpanded to start open, or pass isExpanded with onExpandedChange to control it.
TraceCollapsibleTrigger
The button that opens and closes the row. Put a TraceLine inside it; it adds a chevron after the line.
Also accepts the props of CollapsibleTrigger.
Also accepts the props of CollapsibleTrigger, except asChild.
TraceCollapsibleContent
The detail of a row that expands, indented under the title.
| Prop | Type | Default |
|---|---|---|
keepMounted | boolean | false |
className goes to the inner trace-collapsible-content-inner element, which holds the children.
Also accepts the props of CollapsibleContent.
Also accepts the props of CollapsibleContent, except asChild.
Set keepMounted so nested rows keep their open state while the parent is closed.
The content mutes its text. Give a block with a muted background inside it text-foreground to keep its contrast; Code Block sets its own text color.
Each part sets a data-slot, such as trace-line or trace-collapsible-content, for styling, and the row sets data-status.
Web preview
A Trace is a column of TraceLine rows. Each row has a TraceIcon, a TraceTitle and an optional TraceDescription and status. Wrap a row in TraceCollapsible to show more detail when it expands, or in a Pressable to open a link or a sheet.
Use Trace for the steps an agent takes, such as calling a tool, running a command or editing a file. Use Message for its reply and Marker for notes between turns.
Installation
- Install the following dependencies:
- Copy and paste the following code into
components/ui/trace.tsx:
- Update the import paths to match your project setup.
- Install the following dependencies:
- Copy and paste the following code into
components/ui/trace.tsx:
- Update the import paths to match your project setup.
- Install the following dependencies:
- Copy and paste the following code into
components/ui/trace.tsx:
- Update the import paths to match your project setup.
-
Target iOS 17 or later.
-
Add the Swift package to your app:
- Copy the theme files every view uses:
- Copy the source and every file it uses:
- Add the files to your app target.
- Apply the Compose compiler plugin, enable Compose, set
compileSdkto 37 or higher andminSdkto 24 or higher, and add the dependencies:
- Copy the theme files every view uses:
- Copy the source and every file it uses:
- Update the
com.esuiss.uipackage names to match your project.
Usage
Examples
Static
A TraceLine on its own, for a step with no detail to show.
Web preview
Status
Set status on TraceLine: running pulses the title, error turns the row destructive and pending dims it. Say the state in the title too.
Web preview
Description
Use TraceDescription for secondary text such as a diff stat, a duration or a count after the title.
Web preview
Collapsible
Wrap the row in TraceCollapsible to show more detail when it expands, here the command output.
Web preview
Controlled
Opens and closes a row from outside with open and onOpenChange. Rows start closed; set defaultOpen to start open.
Rows start closed. Use TraceCollapsible(initiallyExpanded:) to start open, or TraceCollapsible(isExpanded:) with a binding to control it.
Rows start closed. Pass initiallyExpanded to start open, or expanded with onExpandedChange to control it.
Web preview
Link
Wraps the TraceLine in a Pressable that opens a URL.
Web preview
This code uses Tailwind classes that need Uniwind or NativeWind. With StyleSheet, pass the same values through the style props.
Group
Rows next to each other in one Trace.
Web preview
Sources
A collapsible row whose detail is a Trace of link rows.
Web preview
This code uses Tailwind classes that need Uniwind or NativeWind. With StyleSheet, pass the same values through the style props.
Steps
A summary row with step rows inside.
Web preview
Commit
A row for each changed file, with the line counts in the description.
Web preview
Whole turn
Three levels: the turn, a summary and the rows, with text between the steps.
Web preview
Reasoning
A thinking row that expands into the reasoning text.
Web preview
Tool calls
Tool calls with their output, including a failed call.
Web preview
Accessibility
- The trigger is a button whose state reads as expanded or collapsed.
TraceIconis hidden from assistive technology, so write the title as a sentence that says what happened.- Status is shown with color and motion, so put it in the title too.
API Reference
Trace
A column of rows.
Also accepts the props of ViewProps.
TraceLine
One row: an icon, a title and an optional description.
| Prop | Type | Default |
|---|---|---|
status | "running" | "error" | "pending" | - |
Also accepts the props of ViewProps.
status is the state of the work the row reports: running pulses the title, error turns the row destructive and pending dims it.
TraceIcon
A 16 pt icon slot, hidden from assistive technology.
Also accepts the props of ViewProps.
TraceTitle
One line of text that truncates. It pulses while the row is running unless the reader prefers reduced motion.
Also accepts the props of Text.
TraceDescription
Secondary text after the title, with tabular numbers.
Also accepts the props of Text.
TraceCollapsible
A row that expands.
| Prop | Type | Default |
|---|---|---|
open | boolean | - |
defaultOpen | boolean | false |
onOpenChange | (open: boolean, details) => void | - |
Rows start closed. Set defaultOpen to start open, or pass open with onOpenChange to control it.
TraceCollapsibleTrigger
The pressable row that opens and closes the detail. It adds a chevron after the line.
TraceCollapsibleContent
The detail of a row, indented under the title with a leading rule.
| Prop | Type | Default |
|---|---|---|
keepMounted | boolean | false |
Set keepMounted to keep the detail mounted while closed, so nested rows keep their state.
TraceStatus
Values: .running, .error, .pending.
Trace
A column of rows.
| Parameter | Type | Default |
|---|---|---|
content | () -> Content | - |
TraceLine
One row: an icon, a title and an optional description.
| Parameter | Type | Default |
|---|---|---|
status | TraceStatus?: .running | .error | .pending | nil |
content | () -> Content | - |
TraceIcon
A 16 pt icon slot, hidden from assistive technology.
| Parameter | Type | Default |
|---|---|---|
content | () -> Content | - |
TraceTitle
One line of text that truncates. It pulses while the row is running unless the reader prefers reduced motion.
| Parameter | Type | Default |
|---|---|---|
_ title | LocalizedStringKey | - |
verbatim | String | - |
Overloads: init(_:), init(verbatim:).
TraceDescription
Secondary text after the title, with tabular numbers.
| Parameter | Type | Default |
|---|---|---|
_ description | LocalizedStringKey | - |
verbatim | String | - |
Overloads: init(_:), init(verbatim:).
TraceCollapsible
A row that expands.
| Parameter | Type | Default |
|---|---|---|
isExpanded | Binding<Bool> | - |
content | () -> Content | - |
initiallyExpanded | Bool | false |
Overloads: init(isExpanded:content:), init(initiallyExpanded:content:).
TraceCollapsibleTrigger
The pressable row that opens and closes the detail. It adds a chevron after the line.
| Parameter | Type | Default |
|---|---|---|
label | () -> Label | - |
TraceCollapsibleContent
The detail of a row, indented under the title with a leading rule.
| Parameter | Type | Default |
|---|---|---|
content | () -> Content | - |
TraceStatus
Values: Running, Error, Pending.
Trace
A column of rows.
| Parameter | Type | Default |
|---|---|---|
modifier | Modifier | Modifier |
content | @Composable ColumnScope.() -> Unit | - |
TraceLine
One row: an icon, a title and an optional description.
| Parameter | Type | Default |
|---|---|---|
modifier | Modifier | Modifier |
status | TraceStatus?: Running | Error | Pending | null |
content | @Composable RowScope.() -> Unit | - |
TraceIcon
A 16 pt icon slot, hidden from assistive technology.
| Parameter | Type | Default |
|---|---|---|
modifier | Modifier | Modifier |
content | @Composable BoxScope.() -> Unit | - |
TraceTitle
One line of text that truncates. It pulses while the row is running unless the reader prefers reduced motion.
Receiver: RowScope.
| Parameter | Type | Default |
|---|---|---|
text | String | - |
modifier | Modifier | Modifier |
TraceDescription
Secondary text after the title, with tabular numbers.
| Parameter | Type | Default |
|---|---|---|
text | String | - |
modifier | Modifier | Modifier |
TraceCollapsible
A row that expands.
| Parameter | Type | Default |
|---|---|---|
expanded | Boolean | - |
onExpandedChange | (Boolean) -> Unit | - |
modifier | Modifier | Modifier |
content | @Composable ColumnScope.() -> Unit | - |
initiallyExpanded | Boolean | false |
Overloads: TraceCollapsible(expanded, onExpandedChange, content), TraceCollapsible(initiallyExpanded, content).
TraceCollapsibleTrigger
The pressable row that opens and closes the detail. It adds a chevron after the line.
| Parameter | Type | Default |
|---|---|---|
modifier | Modifier | Modifier |
content | @Composable RowScope.() -> Unit | - |
TraceCollapsibleContent
The detail of a row, indented under the title with a leading rule.
| Parameter | Type | Default |
|---|---|---|
modifier | Modifier | Modifier |
content | @Composable ColumnScope.() -> Unit | - |