LogViewer

Virtualized monospace console for high-frequency log and stream output

Category: display · WCAG 2.2-AA · log, stream, virtual, console, terminal, monospace

States

Props

PropTypeDefaultDescription
linesReadonlySignal<readonly LogLine[]> | readonly LogLine[]The log lines to display (a signal or array).
rowHeightnumber20Height of each row in pixels, used for virtualization.
overscannumber8Number of extra rows rendered above and below the viewport.
followbooleanWhether the view auto-scrolls to follow new lines (controlled).
onFollowChange(follow: boolean) => voidCalled with the new follow state when it changes.
ansibooleanfalseWhen true, parses ANSI color escape codes into colored spans.
searchstringQuery used to filter and highlight matching lines.
maxHeightstring'24rem'Maximum height of the scroll viewport (CSS length).
labelsLogViewerLabelsOverrides for the component’s user-visible strings (i18n).

Design tokens

When to use

When not to use

How to build an accessible LogViewer in React →

Examples

Streaming build log

Backed by createStreamBuffer; auto-follows the tail

const logs = useStreamBuffer<LogLine>({ capacity: 1000 })
// socket.onmessage = (e) => logs.append({ id: seq++, text: e.data })
<LogViewer lines={logs.signal} />

Static log with levels

<LogViewer lines={[{ id: 1, text: "Build started", level: "info" }, { id: 2, text: "Type error", level: "error" }]} />

ANSI colored output

<LogViewer ansi lines={ansiLines} maxHeight="32rem" />

Related components

← Back to docs