Hulian UIv0.93.5413 components0 components
  • Start
  • Components
  • Blocks
  • Pages
  • Demos
  • Changelog
ChineseEnglish
  • ComponentsComponents
  • ThemeTheme

Collections

  • QuestionCard
  • Table
  • Book3D
  • ProTable
  • PricingTable
  • JsonViewer
  • EditableTable
  • List
  • Descriptions
  • RowActions
  • Tree
  • Card
  • Carousel
  • Video
  • Audio
  • BentoGrid
  • Image
  • MagicCard
  • AnimatedList
  • Marquee
  • Sortable
  • Kanban
  • DesignCanvas
  • LayerTree
  • StageDraw
  • SlideDeck
  • PresenterView
  • ComponentPicker
  • EventStream
  • QueueLane
  • DocumentSheet
  • Novel reader
  • Scheduler
  • Org classroom
  • Danmaku
  • LiveChat
  • LivePlayer
  • LogViewer
  • FileTree
  • CodeReviewThread
  • VirtualList
  • InfiniteScroll
  • LogoLoop
  • BounceCards
  • CardSwap
  • ChromaGrid
  • CircularGallery
  • DomeGallery
  • FlyingPosters
  • InfiniteMenu
  • MagicBento
  • ScrollStack
  • ProfileCard
  • TiltedCard
  • PixelCard
  • DecayCard
  • ReflectiveCard
  • Folder

Charts and Diagrams

  • Flow
  • Diagram
  • Paper
  • SequenceDiagram
  • Sankey
  • Sparkline
  • Funnel
  • Treemap
  • Gantt
  • Heatmap
  • ContributionGraph
  • Legend
  • Chart
  • WorldMap

Information

  • ImageViewer
  • LiveProductCard
  • DiffStat
  • ScoreRing
  • ScoreScale
  • Badge
  • Dot
  • StatusDot
  • Chip
  • FilterChip
  • Coupon
  • Tag
  • Annotation
  • Avatar
  • AvatarCircles
  • User
  • QRCode
  • Comment
  • RelativeTime
  • GitCommit
  • DeployStatus
  • ShieldBadge
  • AwardBadge
  • CreditCard
  • IconTile

Metrics

  • Stat
  • Statistic
  • Meter
  • Timeline
  • NumberTicker

Placeholders

  • Empty
  • Skeleton
  • Watermark

LogViewer

log-viewer

Displays leveled log lines with timestamps, sources, wrapping, and auto-scroll.

Usage

Basic usage

lines Data-driven rendering, level fields colored by level (info/warn/error/success/command).

▸ npm run build
compiling 248 modules…
✓ compiled in 8.1s
2 problems (1 error, 1 warning)
tsx
<LogViewer
  lines={[
    { level: "command", message: "▸ npm run build" },
    { level: "info", message: "compiling 248 modules…" },
    { level: "success", message: "✓ compiled in 8.1s" },
    { level: "error", message: "2 problems (1 error, 1 warning)" },
  ]}
/>

timestamp + source prefix

showTimestamp renders the timestamp at the beginning of the line; line.source weakens the rendering before the main text.

12:00:01▸ npm run build
12:00:01[turbo]scope: 1 package
12:00:02compiling 248 modules…
12:00:05[ts]unused var 'x' at app.tsx:42
12:00:09✓ compiled in 8.1s
12:00:10[lint]2 problems (1 error, 1 warning)
tsx
<LogViewer
  showTimestamp
  lines={[
    { level: "command", timestamp: "12:00:01", message: "▸ npm run build" },
    { level: "warn", timestamp: "12:00:05", source: "[ts]", message: "unused var 'x' at app.tsx:42" },
    { level: "success", timestamp: "12:00:09", message: "✓ compiled in 8.1s" },
  ]}
/>

Streaming append (automatically stick to the bottom)

autoScroll is enabled by default, and new lines are appended to the bottom; the running logic is left on the consumer side, and the component is only rendered.

12:00:01Allocating sandbox…
12:00:01✓ microVM ready (180ms)
tsx
<LogViewer lines={lines} showTimestamp height={220} />

Wrap mode

wrap After opening, long lines will wrap instead of horizontal scrolling, and the entire text can be read even in narrow containers.

Error: connect ECONNREFUSED 127.0.0.1:5432 at TCPConnectWrap.afterConnect. This is a very long log, wrap After opening, it will wrap lines instead of scrolling horizontally, ensuring that it can be read in a narrow container.
tsx
<LogViewer
  wrap
  lines={[
    { level: "error", message: "Error: connect ECONNREFUSED 127.0.0.1:5432 ...This is a very long log" },
  ]}
/>

When to use

Use LogViewer for structured build, CI, and runtime streams that need level styling, timestamps, and bottom-following behavior. It renders real log data; use a terminal mockup for decorative typing demos, or Conversation for AI chat.

Import

ts
import { LogViewer, levelClass } from "@hulianui/ui"

Props

NameTypeDefaultDescription
lines*LogLine[]-Data-driven log lines.
showTimestampbooleanfalseShows each timestamp before its line.
autoScrollbooleantrueFollows new lines only while the user is already at the bottom; scrolling up pauses following until they return.
maxLinesnumber-Renders only the last N lines; 0 or omission keeps all lines. The input array is unchanged.
wrapbooleanfalseWraps long lines; otherwise they scroll horizontally.
heightnumber | string320Scroll-region height.
classNamestring-Custom class name.

LogLine is { level?: LogLevel; message: ReactNode; timestamp?: string; source?: string }.
LogLevel is "info"\|"warn"\|"error"\|"debug"\|"success"\|"command" (info by default; command highlights executed commands or prompt lines, while source, such as "[build]", is muted before the message).

Pitfalls

  • Keep stream timing and append logic in the consumer; LogViewer only renders lines and follows the bottom.
  • autoScroll is sticky, not forced. Its bottom check allows an 8 px tolerance for subpixel and inertial scrolling.
  • Set maxLines for long-running streams to avoid accumulating tens of thousands of DOM nodes.
  • ANSI escape sequences are not parsed. Strip them or map them to LogLine.level before rendering.
  • With the default wrap={false}, long lines scroll horizontally. Enable wrapping in narrow containers when full text must remain visible.

Related

Table · Book3D · ProTable · PricingTable · JsonViewer · EditableTable

PreviousLiveProductCardData DisplayNextFileTree

On this page

  • Usage
  • Documentation
    • When to use
    • Import
    • Props
    • Pitfalls
    • Related