Stack Trace
A failed call and its stack frames, with your own frames first.
Concept, not a real feature. Designed from Linear's danger text, its code font and the code block surface.
import { StackTrace } from "@replicas/ui";
export default function StackTraceDemo() {
return (
<StackTrace.Root defaultOpen style={{ width: "100%", maxWidth: 480 }}>
<StackTrace.Trigger>Failed: Cannot read properties of undefined (reading 'total')</StackTrace.Trigger>
<StackTrace.Content>
<StackTrace.Error type="TypeError">Cannot read properties of undefined (reading 'total')</StackTrace.Error>
<StackTrace.Frames>
<StackTrace.Frame name="formatInvoice" location="app/lib/billing.ts:42:31" />
<StackTrace.Frame name="InvoiceRow" location="app/components/invoice-row.tsx:18:12" />
<StackTrace.Frame name="renderWithHooks" location="node_modules/react-dom/cjs/react-dom.development.js:14985:18" internal />
<StackTrace.Frame name="beginWork" location="node_modules/react-dom/cjs/react-dom.development.js:19049:16" internal />
</StackTrace.Frames>
</StackTrace.Content>
</StackTrace.Root>
);
}Prompt
Copy Prompt hands your agent everything it needs to build the Stack Trace in the Linear style: the measured tokens, the CSS and the structure.
Show Prompt
# Linear Stack Trace
A failed call and its stack frames, with your own frames first.
Build a Stack Trace in this project that looks and behaves like Linear's. Measured from the running Linear app (linear.app). Keep every value exact. Map the tokens onto the project's own theme variables instead of hard-coding them. Use the project's own component library for behaviour, or Base UI primitives if it has none.
Fidelity: Concept, not a real feature. Designed from Linear's danger text, its code font and the code block surface.
## Tokens
| Token | Light | Dark |
| --- | --- | --- |
| `--text-primary` | `lch(9.794% 0 282)` | `lch(100% 0 272)` |
| `--text-tertiary` | `lch(39.176% 1.25 282)` | `lch(61.803% 1.2 272)` |
| `--text-quaternary` | `lch(64.64% 1.25 282)` | `lch(36.975% 1.2 272)` |
| `--danger-text` | `lch(50% 80 29)` | `lch(80% 80 29)` |
| `--code-bg` | `lch(96.2% 0.5 282)` | `lch(7.9% 0.85 272)` |
| `--code-border` | `lch(89.5% 0 282)` | `lch(16.32% 1.48 272)` |
| `--status-red` | `lch(52% 74 29)` | `lch(68% 62 29)` |
| `--focus-ring` | `#5e69d1` | `#5e69d1` |
| `--font-monospace` | `"Berkeley Mono", "SFMono Regular", Consolas, "Liberation Mono", Menlo, Courier, monospace` | `"Berkeley Mono", "SFMono Regular", Consolas, "Liberation Mono", Menlo, Courier, monospace` |
| `--font-size-mini` | `0.75rem` | `0.75rem` |
| `--font-size-small` | `0.8125rem` | `0.8125rem` |
| `--font-weight-medium` | `500` | `500` |
| `--radius-control` | `8px` | `8px` |
| `--speed-highlight-fade-in` | `0s` | `0s` |
| `--speed-quick` | `0.1s` | `0.1s` |
| `--speed-highlight-fade-out` | `0.15s` | `0.15s` |
| `--ease-spring-collapse` | `linear(0, 0.0183, 0.0632, 0.1233, 0.191, 0.2611, 0.3304, 0.3969, 0.4593, 0.517, 0.5698, 0.6177, 0.6608, 0.6996, 0.7342, 0.7651, 0.7925, 0.8169, 0.8384, 0.8575, 0.8744, 0.8893, 0.9025, 0.9141, 0.9243, 0.9333, 0.9413, 0.9483, 0.9545, 0.9599, 0.9647, 0.9689, 0.9726, 0.9759, 0.9788, 0.9813, 0.9836, 0.9855, 0.9873, 0.9888, 1)` | `linear(0, 0.0183, 0.0632, 0.1233, 0.191, 0.2611, 0.3304, 0.3969, 0.4593, 0.517, 0.5698, 0.6177, 0.6608, 0.6996, 0.7342, 0.7651, 0.7925, 0.8169, 0.8384, 0.8575, 0.8744, 0.8893, 0.9025, 0.9141, 0.9243, 0.9333, 0.9413, 0.9483, 0.9545, 0.9599, 0.9647, 0.9689, 0.9726, 0.9759, 0.9788, 0.9813, 0.9836, 0.9855, 0.9873, 0.9888, 1)` |
| `--duration-spring-collapse` | `185ms` | `185ms` |
## CSS
Scoped under `[data-style="linear"]`; dark rules sit under `[data-theme="dark"]`. The `ui-*` classes and data attributes match the structure below.
```css
[data-style="linear"] {
.ui-stack-trace {
display: flex;
flex-direction: column;
min-width: 0;
color: var(--text-tertiary);
font-family: inherit;
font-size: var(--font-size-small);
line-height: 20px;
}
.ui-stack-trace-trigger {
box-sizing: border-box;
display: inline-flex;
align-items: center;
align-self: flex-start;
gap: 8px;
max-width: 100%;
height: 28px;
margin: 0 0 0 -6px;
padding: 0 8px 0 6px;
border: none;
border-radius: 6px;
background-color: transparent;
color: var(--danger-text);
font: inherit;
text-align: start;
user-select: none;
cursor: default;
transition: background-color var(--speed-highlight-fade-out);
&:focus-visible {
outline: 1px solid var(--focus-ring);
}
@media (hover: hover) {
&:hover {
background-color: color-mix(in lch, var(--status-red) 8%, transparent);
transition-duration: var(--speed-highlight-fade-in);
}
}
}
.ui-stack-trace-icon {
display: flex;
flex-shrink: 0;
align-items: center;
justify-content: center;
width: 16px;
color: var(--status-red);
& svg {
width: 14px;
height: 14px;
}
}
.ui-stack-trace-title {
min-width: 0;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.ui-stack-trace-chevron {
width: 8px;
height: 8px;
flex-shrink: 0;
margin-left: -2px;
background-color: currentColor;
opacity: 0.6;
clip-path: polygon(25% 12%, 85% 50%, 25% 88%);
transition: transform var(--speed-quick) ease-in-out;
& path {
display: none;
}
[data-panel-open] > & {
transform: rotate(90deg);
}
}
.ui-stack-trace-content {
box-sizing: border-box;
height: var(--collapsible-panel-height);
padding: 4px 1px 1px;
overflow: hidden;
transition:
height var(--duration-spring-collapse) var(--ease-spring-collapse),
padding-block var(--duration-spring-collapse) var(--ease-spring-collapse);
&[data-starting-style],
&[data-ending-style] {
height: 0;
padding-block: 0;
}
}
.ui-stack-trace-error {
box-sizing: border-box;
margin: 0;
padding: 10px 12px 8px;
border: 0.5px solid var(--code-border);
border-bottom: none;
border-radius: var(--radius-control) var(--radius-control) 0 0;
background-color: var(--code-bg);
color: var(--text-primary);
font-family: var(--font-monospace);
font-size: var(--font-size-mini);
line-height: 18px;
overflow-wrap: anywhere;
}
.ui-stack-trace-error-type {
color: var(--danger-text);
font-weight: var(--font-weight-medium);
}
.ui-stack-trace-frames {
box-sizing: border-box;
margin: 0;
padding: 0 12px 10px;
overflow-x: auto;
border: 0.5px solid var(--code-border);
border-top: none;
border-radius: 0 0 var(--radius-control) var(--radius-control);
background-color: var(--code-bg);
font-family: var(--font-monospace);
font-size: var(--font-size-mini);
line-height: 20px;
list-style: none;
.ui-stack-trace-error + & {
padding-top: 2px;
}
&:first-child {
padding-top: 10px;
border-top: 0.5px solid var(--code-border);
border-radius: var(--radius-control);
}
}
.ui-stack-trace-frame {
padding-left: 16px;
white-space: nowrap;
}
.ui-stack-trace-at {
color: var(--text-quaternary);
}
.ui-stack-trace-function {
color: var(--text-primary);
}
.ui-stack-trace-location {
color: var(--text-tertiary);
}
.ui-stack-trace-frame[data-internal] :is(.ui-stack-trace-function, .ui-stack-trace-location) {
color: var(--text-quaternary);
}
@media (prefers-reduced-motion: reduce) {
.ui-stack-trace-chevron,
.ui-stack-trace-content {
transition: none;
}
}
}
```
## Structure
How Replicas assembles it on Base UI.
```tsx
import { Collapsible as BaseCollapsible } from "@base-ui/react/collapsible";
import type { ComponentProps, ReactNode } from "react";
import { join } from "./utils";
function Root({ className, ...props }: Omit<BaseCollapsible.Root.Props, "className"> & { className?: string }) {
return <BaseCollapsible.Root className={join("ui-stack-trace", className)} {...props} />;
}
type TriggerProps = Omit<BaseCollapsible.Trigger.Props, "className"> & {
className?: string;
icon?: ReactNode;
};
function Trigger({ className, icon, children, ...props }: TriggerProps) {
return (
<BaseCollapsible.Trigger className={join("ui-stack-trace-trigger", className)} {...props}>
<span className="ui-stack-trace-icon" aria-hidden>
{icon ?? (
<svg viewBox="0 0 16 16" fill="none">
<circle cx="8" cy="8" r="6.25" stroke="currentColor" strokeWidth="1.5" />
<path d="M6 6l4 4M10 6l-4 4" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" />
</svg>
)}
</span>
<span className="ui-stack-trace-title">{children}</span>
<svg className="ui-stack-trace-chevron" viewBox="0 0 16 16" fill="none" aria-hidden>
<path d="M6 4l4 4-4 4" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round" />
</svg>
</BaseCollapsible.Trigger>
);
}
function Content({ className, ...props }: Omit<BaseCollapsible.Panel.Props, "className"> & { className?: string }) {
return <BaseCollapsible.Panel className={join("ui-stack-trace-content", className)} {...props} />;
}
type ErrorProps = ComponentProps<"p"> & { type?: ReactNode };
function ErrorMessage({ className, type, children, ...props }: ErrorProps) {
return (
<p className={join("ui-stack-trace-error", className)} {...props}>
{type ? <span className="ui-stack-trace-error-type">{type}: </span> : null}
<span className="ui-stack-trace-error-message">{children}</span>
</p>
);
}
function Frames({ className, ...props }: ComponentProps<"ol">) {
return <ol className={join("ui-stack-trace-frames", className)} {...props} />;
}
type FrameProps = ComponentProps<"li"> & {
name?: ReactNode;
location: ReactNode;
internal?: boolean;
};
function Frame({ className, name, location, internal = false, ...props }: FrameProps) {
return (
<li className={join("ui-stack-trace-frame", className)} data-internal={internal || undefined} {...props}>
<span className="ui-stack-trace-at">at </span>
{name ? <span className="ui-stack-trace-function">{name} </span> : null}
<span className="ui-stack-trace-location">{location}</span>
</li>
);
}
export const StackTrace = {
Root,
Trigger,
Content,
Error: ErrorMessage,
Frames,
Frame,
};
```
## Example
```tsx
import { StackTrace } from "@replicas/ui";
export default function StackTraceDemo() {
return (
<StackTrace.Root defaultOpen style={{ width: "100%", maxWidth: 480 }}>
<StackTrace.Trigger>Failed: Cannot read properties of undefined (reading 'total')</StackTrace.Trigger>
<StackTrace.Content>
<StackTrace.Error type="TypeError">Cannot read properties of undefined (reading 'total')</StackTrace.Error>
<StackTrace.Frames>
<StackTrace.Frame name="formatInvoice" location="app/lib/billing.ts:42:31" />
<StackTrace.Frame name="InvoiceRow" location="app/components/invoice-row.tsx:18:12" />
<StackTrace.Frame name="renderWithHooks" location="node_modules/react-dom/cjs/react-dom.development.js:14985:18" internal />
<StackTrace.Frame name="beginWork" location="node_modules/react-dom/cjs/react-dom.development.js:19049:16" internal />
</StackTrace.Frames>
</StackTrace.Content>
</StackTrace.Root>
);
}
```
## Foundations
The rest of the Linear style, as a skill: https://replicas.raphaelsalaja.com/skills/linear/SKILL.md