Skip to content

Widgets Overview

@termuijs/widgets gives you the building blocks for terminal UIs. Every widget extends the base Widget class, manages its own render rectangle, and only repaints when something actually changes.

Installation

·CODE
npm install @termuijs/widgets

All Widgets

WidgetCategoryDescription
BoxDisplayContainer with borders, padding, and flex layout
TextDisplayStyled text with color, bold, italic, dim, underline
LogViewDisplayScrollable log panel with auto-scroll and max buffer
TreeDisplayCollapsible tree for hierarchical data
JSONViewDisplayCollapsible, navigable JSON tree viewer
DiffViewDisplayUnified diff viewer with colored +/- lines
StreamingTextDisplayTypewriter effect with configurable speed and cursor
ChatMessageDisplayChat bubble with role-aware styling (user/assistant/system)
ToolCallDisplayAI tool call display with status and collapsible args/result
BigTextDisplayLarge ASCII art banner text, no external deps
GradientDisplayText with per-character 256-color gradient
MarkdownDisplayRenders Markdown text with headings, bold, and code blocks
CodeDisplaySyntax-highlighted code block
HighlightDisplayInline text with highlight spans
TypewriterDisplayAnimated character-by-character text reveal
DigitsDisplayLarge ASCII-art digit display
MarqueeDisplayHorizontally scrolling text ticker
CalloutDisplayStyled callout block with icon and variant
KbdDisplayKeyboard shortcut badge
TableDataData table with column alignment and headers
GaugeDataPercentage indicator with label and color thresholds
SparklineDataInline bar chart for time-series data
BarChartDataHorizontal or vertical bar chart with groups
LineChartDataASCII line plot of a single series with optional X/Y axes
HeatMapData2D matrix with color-scale shading and row/col labels
KeyValueDataAligned key–value pairs with configurable separator
DefinitionDataTerm (bold) + definition stacked pairs
StatusIndicatorDataUp/down status dot with label (green when up, red when down)
DataGridData2D-virtualized grid with sorting and filtering
StackedBarChartDataStacked bar chart with series labels
HistogramDataFrequency distribution chart
PieChartDataPie chart with labeled slices and a legend
BulletChartDataBullet chart for performance-against-target display
CandlestickChartDataOHLC candlestick chart for financial data
AreaChartDataFilled area chart for time-series data
ScatterPlotDataXY scatter plot with configurable dot markers
RadarChartDataSpider/radar chart for multi-axis comparison
GanttChartDataTimeline chart for task and schedule display
BrailleCanvasDataHigh-resolution canvas using Unicode Braille characters
StatDataLarge single metric with label and optional delta
HexdumpDataHex + ASCII dump viewer for binary data
TreeTableDataCollapsible tree with sortable table columns
CardLayoutBordered container with optional title in the border
ScrollViewLayoutHeight-bounded scrollable container with arrow-key navigation
CenterLayoutCenters a single child horizontally, vertically, or both
ColumnsLayoutEvenly-split column layout from an array of widgets
GridLayoutCSS-grid-like layout: items flow left-to-right, wrap every N columns
SidebarLayoutNavigable sidebar with items, badges, and active highlight
BannerLayoutFull-width alert with title, body, and variant color
StatusMessageLayoutCompact single-line status with icon and variant color
SplitPaneLayoutResizable split pane - horizontal or vertical
StackLayoutEvenly-spaced vertical or horizontal stack
MasonryLayoutVariable-height masonry column layout
FillLayoutFills remaining space in a flex container
RuleLayoutFull-width horizontal or vertical rule with optional label
DividerLayoutSection separator - horizontal or vertical
AspectRatioLayoutConstrains a child widget to a fixed aspect ratio
DirectoryTreeLayoutFile system tree with icons and expand/collapse
ProgressBarFeedbackHorizontal progress indicator with customizable fill
SpinnerFeedbackAnimated loading spinner - respects NO_MOTION
SkeletonFeedbackAnimated loading placeholder (pulse/shimmer)
MultiProgressFeedbackMultiple labeled progress bars in one widget
CommandPaletteFeedbackSearchable, filterable command menu
ScrollbarFeedbackStandalone scrollbar indicator (vertical or horizontal)
ProgressCircleFeedbackCircular progress ring with percentage label
LoadingDotsFeedbackAnimated ellipsis loading indicator
StepperFeedbackStep-by-step progress display for sequential tasks
TimerFeedbackCountdown or elapsed time display
ClockFeedbackLive clock display
MeterFeedbackCompact level meter with configurable thresholds
NotificationBadgeFeedbackNumeric badge overlaid on another widget
BadgeFeedbackInline status badge with variant color
TagFeedbackCompact label tag with optional close action
EmptyStateFeedbackPlaceholder shown when a list or view has no content
PlaceholderFeedbackGeneric placeholder box for layout scaffolding
TooltipFeedbackHover or focus-triggered tooltip overlay
ShortcutBarFeedbackBottom bar listing active keyboard shortcuts
TaskListFeedbackChecklist with status icons per item
TimelineFeedbackVertical event timeline with timestamps and labels
CarouselFeedbackHorizontally paged display widget
WatermarkFeedbackBackground text watermark for overlays
AvatarFeedbackUser avatar with initials or image fallback
CollapsibleFeedbackToggle-able collapsible content section
AccordionFeedbackGrouped collapsible sections with single-open mode
ThinkingBlockFeedbackAnimated thinking indicator for AI streaming
ListInputKeyboard-navigable list for small datasets
TextInputInputSingle-line text input with cursor and placeholder
VirtualListInputScroll-virtualized list; renders only visible rows, any dataset size
RangeInputInputDual-handle range slider for selecting a min/max value
KnobInputCircular dial for numeric value input
PinInputInputDiscrete code entry for PINs and OTPs
CalendarInputMonth calendar with keyboard date selection
CanvasInput2D drawing canvas with pixel-level control
PtyInputTerminal multiplexer widget for embedded PTY sessions
OrderedListDisplayNumbered list with configurable markers
DockLayoutEdge-anchored dock bar for persistent widget placement

Quick Example

Build a simple dashboard by composing widgets and passing the root to App:

·CODE
import { App } from '@termuijs/core'
import { Box, Text, ProgressBar, Spinner } from '@termuijs/widgets'

// Create widgets
const title = new Text('Dashboard', { bold: true, fg: 'cyan' })
const spinner = new Spinner({}, { preset: 'dots', color: { type: 'named', name: 'green' } })
const loadingText = new Text('Loading data...')
const cpuLabel = new Text('CPU Usage')
const cpuBar = new ProgressBar({ width: 30 }, { value: 0.73, fillColor: { type: 'named', name: 'green' } })

// Compose layout
const row = new Box({ flexDirection: 'row', gap: 2 })
row.addChild(spinner)
row.addChild(loadingText)

const column = new Box({ flexDirection: 'column', gap: 1 })
column.addChild(cpuLabel)
column.addChild(cpuBar)

const root = new Box({ border: 'round', padding: 1, flexDirection: 'column', gap: 1 })
root.addChild(title)
root.addChild(row)
root.addChild(column)

// Mount
const app = new App(root, { fullscreen: true })
await app.mount()
// ╭──────────────────────────────────╮
// │ Dashboard                        │
// │ ⠋ Loading data...               │
// │ CPU Usage                        │
// │ ████████████████████░░░░░ 73%    │
// ╰──────────────────────────────────╯

VirtualList: handle any dataset size

VirtualList renders only the rows visible in the viewport. A list of 1,000,000 items renders as fast as a list of 10.

·CODE
import { App } from '@termuijs/core'
import { VirtualList } from '@termuijs/widgets'

const list = new VirtualList({
    totalItems: 1_000_000,
    renderItem: (index) => `Log line \${index}: some message content`,
    onSelect:   (index) => console.log('Selected:', index),
})

const app = new App(list, { fullscreen: true })
app.events.on('key', (e) => {
    if (e.key === 'up')    list.selectPrev()
    if (e.key === 'down')  list.selectNext()
    if (e.key === 'enter') list.confirm()
    if (e.key === 'home')  list.selectFirst()
    if (e.key === 'end')   list.selectLast()
})
await app.mount()

// Handles 1M items. renders ~26 rows with scrollbar

Common Patterns

Status Dashboard

·CODE
import { Box, Text, Gauge, StatusIndicator, ProgressBar } from '@termuijs/widgets'

// Build a status row. Second arg is the up/down flag.
const apiStatus = new StatusIndicator('API', true)
const dbStatus = new StatusIndicator('DB', true)
const cacheStatus = new StatusIndicator('Cache', false)

const statusRow = new Box({ flexDirection: 'row', gap: 4 })
statusRow.addChild(apiStatus)
statusRow.addChild(dbStatus)
statusRow.addChild(cacheStatus)

// Resource gauges
const cpuBar = new ProgressBar({ width: 40 }, { value: 0.72, fillColor: { type: 'named', name: 'green' } })
const memBar = new ProgressBar({ width: 40 }, { value: 0.58, fillColor: { type: 'named', name: 'cyan' } })
const diskGauge = new Gauge('Disk')
diskGauge.setValue(0.45)

const panel = new Box({ flexDirection: 'column', gap: 1 })
panel.addChild(statusRow)
panel.addChild(new Text('Resource Usage', { dim: true }))
panel.addChild(cpuBar)
panel.addChild(memBar)
panel.addChild(diskGauge)

Log Viewer

·CODE
import { LogView } from '@termuijs/widgets'

const logs = new LogView({
    maxLines: 1000,
    autoScroll: true,
})

logs.append({ text: '[INFO]  Server started', color: 'green' })
logs.append({ text: '[WARN]  Memory usage high', color: 'yellow' })
logs.append({ text: '[ERROR] Connection reset', color: 'red' })

Data Table

·CODE
import { Table } from '@termuijs/widgets'

const table = new Table({
    columns: [
{ key: 'pid',  header: 'PID',     width: 8  },
{ key: 'name', header: 'Process',  width: 20 },
{ key: 'cpu',  header: 'CPU%',     width: 8, align: 'right' },
{ key: 'mem',  header: 'Memory',   width: 10 },
    ],
    rows: processes,
})

See also

  • Display Widgets - StreamingText, ChatMessage, ToolCall, JSONView, DiffView, BigText, Gradient
  • Layout Widgets - Card, ScrollView, Center, Columns, Sidebar, KeyValue, Definition, Banner, StatusMessage
  • Chart Widgets - BarChart, LineChart, HeatMap, Sparkline
  • Feedback Widgets - Spinner, ProgressBar, Skeleton, MultiProgress, CommandPalette
  • VirtualList: Full reference for the virtualized list
  • @termuijs/ui: Higher-level composites: Select, Tabs, Modal, Toast, Tree
  • Core Layout: Flexbox properties that control widget positioning
  • TSS: Style widgets with CSS-like theming and variables