Updated
Stack Trace
NewCustomize
Color
Width460px
Installation
npx shadcn@latest add https://uibrik.com/r/stack-trace.jsonInstall the packages
npm install @tabler/icons-react motionAdd the cn helper
Imports
cnfrom@/lib/utils, whichshadcn initcreates. Add it by hand without shadcn.Copy the source into your project
components/uibrik/stack-trace/stack-trace.tsx"use client"; // An error card that stays small until you need it. At rest it shows the error, // how often it fired and a bar per hour. The frame that threw sits on top; a // click opens its source with the failing line marked. The rest of the stack // unfolds one frame after another, and runs of library frames fold into a // single row you can open on their own. Every reveal animates height only, so // text never scales. import { IconCheck, IconChevronDown, IconCopy } from "@tabler/icons-react"; import { AnimatePresence, motion, useReducedMotion } from "motion/react"; import { useEffect, useId, useMemo, useRef, useState, type ReactNode } from "react"; import { cn } from "@/lib/utils"; const EASE_OUT: [number, number, number, number] = [0.23, 1, 0.32, 1]; const OPEN = { type: "spring", duration: 0.38, bounce: 0 } as const; export type StackFrame = { /** Function name, e.g. "formatPrice". */ fn: string; /** File path, e.g. "src/lib/money.ts". */ file: string; line: number; column?: number;
Adds the files to
components/uibrik/stack-trace and installs @tabler/icons-react and motion. With the @uibrik namespace set up: npx shadcn@latest add @uibrik/stack-trace.Usage
import { StackTrace } from "@/components/uibrik/stack-trace/stack-trace";const message = "Cannot read properties of undefined (reading 'amount')";const frames = [ { fn: "formatPrice", file: "src/lib/money.ts", line: 14, column: 22, source: { start: 10, lines: [ "export function formatPrice(item: LineItem) {", " const currency = item.currency ?? \"USD\";", " const fmt = formatter(currency);", "", " return fmt.format(item.price.amount / 100);", "}", ], }, }, { fn: "CartRow", file: "src/components/cart/cart-row.tsx", line: 31, column: 9, source: { start: 28, lines: [" return (", " <li className=\"row\">", " <span>{item.name}</span>", " <span>{formatPrice(item)}</span>", " </li>", " );"], }, }, // …6 more];const events = [3, 2, 4, 2, 1, 2, 3, 5, 4, 6, 8, 12, 9, 7, 14, 22, 31, 26, 18, 12, 9, 11, 7, 5];<StackTrace type="TypeError" message={message} color="#e5484d" eventsLabel="24h" defaultOpen={false} defaultExpanded={false} width={460} frames={frames} events={events} users={214} tags={["Chrome 131", "v2.4.1", "checkout"]}/>Where to use Stack Trace
Error monitoring dashboards
Each issue reads in one line, and the source is a click away instead of a page away.
Pairs with Uptime Bar
Developer tool landing pages
An error that unfolds into its stack and source shows what the product does without a screenshot.
Pairs with Terminal Demo
Crash reports in admin panels
Library frames fold away, so the frames from your own code are the ones people read.
Props
StackTrace- type
- Type string
- "TypeError"
- Error class, shown in the pill.
- message
- Type string
- "Cannot read properties of undefined (reading 'amount')"
- The error message.
- color
- Type string
- "#e5484d"
- Colour of the error pill, the peak bar and the failing line.
- eventsLabel
- Type string
- "24h"
- Span the bars cover.
- defaultOpen
- Type boolean
- false
- Show the failing frame's source on mount.
- defaultExpanded
- Type boolean
- false
- Show every frame on mount.
- width
- Type number
- 460
- Width of the card; never wider than its container.
- frames
- Type { fn: string; file: string; line: number; column?: number; inApp?: boolean; source?: { start: number; lines: string[] } }[]
- –
- Innermost frame first. Frames with inApp false fold into library rows; frames with source open to show it.
- events
- Type number[]
- –
- Events per bucket, oldest first; drawn as the bars in the header.
- users
- Type number
- 214
- People affected.
- tags
- Type string[]
- –
- Short facts in the footer, e.g. browser and release.
- className
- Type string
- –
- Classes for the wrapper.