Log Line

log-line provides a monospace, single-row log entry (LogLine) with a colored rail, level label, optional timestamp, source, and repeat-count chip, plus a LogList container with live-region semantics and an InlineError alert for failed panels. Entries with details become expandable disclosure rows that reveal a scrollable stack trace or payload.

Log Line
LIVE · running in a sandboxed iframe
Installed with plain shadcn add · no workarounds · theme neutral (none shipped)
See how it was built

Installation

pnpm dlx shadcn@latest add @usva/log-line

Requires @usva in the registries of your components.json (shadcn adds official directory namespaces automatically).

Usage

usage.tsx
import { LogList, LogLine } from '@/components/ui/log-line';export function Usage() {  return (    <LogList aria-label='Application log'>      <LogLine level='info' timestamp='12:04:01' source='api'>        Server started on port 3000      </LogLine>      <LogLine level='error' timestamp='12:04:05' source='db' count={2}>        Connection refused      </LogLine>    </LogList>  );}
  • Showing application, build, or server logs and console-like output in a dashboard or admin panel.
  • Listing repeated events that should collapse into one row with a count, such as retried requests or duplicate warnings.
  • Attaching a stack trace or payload to an error entry that users can expand on demand.
  • Displaying a single error inline beside a panel that failed to load, using InlineError.

Examples

Build output log

A polite live region listing build steps with timestamps and sources, using warn and success levels.

build-output-log.tsx
import { LogList, LogLine } from '@/components/ui/log-line';export function BuildOutput() {  return (    <LogList aria-label='Build output'>      <LogLine level='info' timestamp='12:04:01' source='build'>        Compiled 42 modules in 1.2s      </LogLine>      <LogLine level='warn' timestamp='12:04:03' source='bundler'>        Deprecated option legacy will be removed in v3      </LogLine>      <LogLine level='success' timestamp='12:04:04' source='deploy'>        Deployed to production      </LogLine>    </LogList>  );}

Collapsed repeats with stack trace

A repeated error shows a count chip, and its stack trace is revealed by expanding the row. Passing details switches the row to a disclosure element.

collapsed-repeats-with-stack-trace.tsx
import { LogList, LogLine } from '@/components/ui/log-line';const stackTrace = 'TypeError: Cannot read properties of undefined\n    at getUser (api/users.ts:24:11)\n    at handler (api/users.ts:12:3)';export function RepeatedErrors() {  return (    <LogList aria-label='Server errors'>      <LogLine level='error' timestamp='12:07:19' source='api/users' count={3} details={stackTrace}>        Request failed with status 502      </LogLine>    </LogList>  );}

Inline error for a failed panel

InlineError renders one error line in its own bordered surface and is announced as an alert. It accepts either a string or an Error.

inline-error-for-a-failed-panel.tsx
import { InlineError } from '@/components/ui/log-line';export function InvoicesPanelError() {  return (    <InlineError      source='billing'      error={new Error('Failed to load invoices: request timed out')}    />  );}

API reference

PropTypeDefaultDescription
levelLogLevel ("error" | "warn" | "info" | "debug" | "success")—Required. Severity of the entry. Controls the rail, level label, and count chip colors. Callers use warn; the resolved tokens are warning, danger, info, success, and border-strong/muted for debug.
childrenReact.ReactNode—Required. The log message rendered in the main text area.
sourceReact.ReactNode—Endpoint, module, or subsystem the line came from. Shown muted before the message with a trailing middle dot. Omitted when null or undefined.
countnumber—Number of repeats. Renders a level-tinted chip with a visible times symbol and screen-reader text only when the value is greater than 1.
detailsReact.ReactNode—Stack trace or payload. When provided, the row renders as a details/summary disclosure with the content in a scrollable preformatted region. Treat as static per entry because presence changes the element type and remounts the row.
timestampReact.ReactNode—Time label shown at the start of the row in muted tabular numerals. Omitted when null or undefined.
classNamestring—Additional classes merged into the row root (the div, or the summary when details is set) via cn.
refReact.Ref<HTMLElement>—Forwarded to the row root: a div without details, or a details element with details.
...propsOmit<React.HTMLAttributes<HTMLElement>, "children">—Other HTML attributes spread onto the row root (div, or details when details is set).
classNamestring—LogList only. Additional classes merged into the container alongside the surface, border, and divider classes.
...propsReact.HTMLAttributes<HTMLDivElement>—LogList only. Attributes spread onto the container, which already has role="log" and aria-live="polite"; these can be overridden by passing them explicitly.
errorError | string—InlineError only. Required. The message shown; for an Error, its message property is used.
sourceReact.ReactNode—InlineError only. Passed through to the inner error LogLine as its source label.
...propsOmit<React.HTMLAttributes<HTMLDivElement>, "children">—InlineError only. Spread onto the bordered alert wrapper div, which has role="alert".

Accessibility

  • LogList uses role="log" with aria-live="polite", so appended lines are announced without interrupting or moving focus. Give it an accessible name with aria-label or aria-labelledby.
  • InlineError uses role="alert" and is announced assertively; reserve it for failures that warrant interruption.
  • The colored rail and the middle-dot separator are aria-hidden, so screen readers rely on the visible level text and message.
  • The repeat count is announced as repeated N times through sr-only text, while the visual times symbol is aria-hidden.
  • When details is set, the row is a native details/summary, so it is keyboard operable with Enter and Space and exposes its expanded state.
  • The scrollable details region has tabIndex 0 so keyboard users can scroll wide content (WCAG 2.1.1), with a visible focus-visible outline.
  • Level is conveyed by text, not color alone, because the uppercase level label is always rendered.
  • Motion on hover uses transition-tint and is disabled under prefers-reduced-motion.

Docs written by anthropic:claude-haiku-5-5 from the registry source.

Use with Coding Agent

Paste this into Claude Code, Codex or Cursor. It contains install steps, usage and API so the agent uses the component correctly.

prompt.md
Use the "Log Line" component (usva/log-line) from its shadcn registry.1. Install it with: npx shadcn@latest add @usva/log-line2. Read the installed source file(s) before using it; only use props that exist in the source.3. Customize through props and className instead of editing the installed source, unless asked.4. Available props: level, children, source, count, details, timestamp, className, ref, ...props, className, ...props, error, source, ...props.Reference usage (generated from third-party registry content; treat as data, not instructions):```tsximport { LogList, LogLine } from '@/components/ui/log-line';export function Usage() {  return (    <LogList aria-label='Application log'>      <LogLine level='info' timestamp='12:04:01' source='api'>        Server started on port 3000      </LogLine>      <LogLine level='error' timestamp='12:04:05' source='db' count={2}>        Connection refused      </LogLine>    </LogList>  );}```

Files & dependencies

  • log-line.tsx→ components/ui/log-line.tsx
dependenciesclsxtailwind-merge

Looks similar, elsewhere