Log Viewer
NewStreaming logs with level filters and counts, search highlighting, wrapping and follow mode that pauses when you scroll up.
web · production
Installation
$ pnpm dlx shadcn@latest add @synccn/log-viewerFirst time in this project? Connect synccn with one command.
Usage
import { LogViewer } from "@/components/ui/log-viewer";<LogViewer lines={lines} title="web · production" />API reference
Generated from the component's TypeScript types, so it always matches the code.
LogViewer
Streaming log output with level filters, search, line wrapping and follow mode. New lines stay in view while you're at the bottom; scroll up to read and a "new lines" button appears instead of the view jumping.
- linesrequired
LogLine[]Lines, oldest first. Append to stream.
- follow
booleanDefault
trueKeeps the newest line in view while the person is at the bottom. Scrolling up pauses it.
- height
numberDefault
320Height of the scrolling area, in pixels.
- maxLines
numberDefault
1000Only the newest lines are rendered beyond this.
- formatTime
(date: Date) => stringDefault
utcTimeFormats timestamps. Defaults to UTC HH:MM:SS.mmm, which renders the same on the server and in the browser.
- defaultLevels
"debug" | "info" | "warn" | "error"[]Default
LEVELSLevels shown at first.
- title
React.ReactNodeHeading shown in the toolbar.
- actions
React.ReactNodeExtra buttons for the toolbar, such as Clear or Download.
- className
stringExtra classes for the root element.
Dependencies
Read from the component's imports when the site builds. The CLI installs all of these for you.
Helpers
- lib/utilscn (merges class names)
npm packages
- clsx for cn()
- tailwind-merge for cn()
- lucide-react for ArrowDown, Search, WrapText
Keyboard
- TabMove between level filters, search, wrap and the log
- ↑or↓Scroll the focused log
Accessibility
- The output is a log region that isn't read aloud line by line; new lines arriving while scrolled up are announced as a count.
- Level filters are toggle buttons with aria-pressed, and each line's level is written out for screen readers.
From the source
Read from this component's code when the site builds, so it can't drift.
- ARIA roles: group, log
- ARIA attributes: aria-label, aria-live, aria-pressed
- Shows a visible focus ring for keyboard users
- Includes text only screen readers hear
- Labels are tied to their controls
- Announces changes to screen readers