Renderables - Panel, Table, Tree, Syntax, and Progress Bar.
Basic text rendering with markup support.
import { Text } from "terminal-richjs";
const text = new Text("Hello, [bold]World[/bold]!");
console.print(text);A bordered container for any content.
import { Panel } from "terminal-richjs";
const panel = new Panel("Content goes here", {
title: "Panel Title",
titleAlign: "left", // 'left' | 'center' | 'right'
subtitle: "Subtitle",
subtitleAlign: "right",
box: "rounded",
borderStyle: "cyan",
padding: 1,
expand: true,
});
console.print(panel);| Option | Type | Default | Description |
|---|---|---|---|
title | string | - | Title in top border |
titleAlign | 'left' | 'center' | 'right' | 'center' | Title alignment |
subtitle | string | - | Subtitle in bottom border |
box | BoxStyle | 'rounded' | Box drawing style |
borderStyle | Style | string | 'dim' | Border color/style |
padding | number | [v, h] | [t, r, b, l] | 1 | Inner padding |
expand | boolean | true | Expand to full width |
// Create a panel that fits its content
const fitted = Panel.fit("Content", { title: "Fitted" });Create formatted tables with headers, footers, and styling.
import { Table } from "terminal-richjs";
const table = new Table({
title: "My Table",
box: "rounded",
rowStyles: ["", "dim"], // Alternating row styles
showHeader: true,
showFooter: false,
showLines: false,
caption: "Table caption",
});
table.addColumn("Name", { justify: "left", style: "bold" });
table.addColumn("Age", { justify: "right" });
table.addColumn("City", { justify: "center" });
table.addRow("Alice", "30", "New York");
table.addRow("Bob", "25", "San Francisco");
table.addFooter("Total", "2", "-");
console.print(table);| Option | Type | Default | Description |
|---|---|---|---|
title | string | - | Table title |
caption | string | - | Table caption |
box | BoxStyle | 'rounded' | Box drawing style |
showHeader | boolean | true | Show header row |
showFooter | boolean | false | Show footer row |
showLines | boolean | false | Row separators |
headerStyle | Style | string | 'bold cyan' | Header style |
rowStyles | string[] | [] | Alternating row styles |
| Option | Type | Default | Description |
|---|---|---|---|
header | string | - | Header text |
style | Style | string | - | Cell style |
justify | 'left' | 'center' | 'right' | 'left' | Alignment |
width | number | - | Fixed width |
minWidth / maxWidth | number | - | Width constraints |
Visualize hierarchical data structures.
import { Tree } from "terminal-richjs";
const tree = new Tree("š root", {
guideStyle: "#6e7681 dim",
hideRoot: false,
});
const folder1 = tree.add("š folder1");
folder1.add("š file1.txt");
folder1.add("š file2.txt");
const folder2 = tree.add("š folder2");
const subfolder = folder2.add("š subfolder");
subfolder.add("š file3.txt");
tree.add("š README.md");
console.print(tree);Output:
š root
āāā š folder1
ā āāā š file1.txt
ā āāā š file2.txt
āāā š folder2
ā āāā š subfolder
ā āāā š file3.txt
āāā š README.md
āāā āāā āā£āā āāā āā āā āāā ā|-- \-- |`Syntax-highlighted code with multiple themes.
import { Syntax } from "terminal-richjs";
const code = `function hello(name: string): void {
console.log(\`Hello, \${name}!\`);
}`;
const syntax = new Syntax(code, "typescript", {
theme: "monokai",
lineNumbers: true,
startLine: 1,
highlightLines: [2],
wordWrap: false,
});
console.print(syntax);
// Load from file
const fromFile = Syntax.fromPath("./src/index.ts", {
theme: "dracula",
lineNumbers: true,
});| Option | Type | Default | Description |
|---|---|---|---|
theme | string | 'monokai' | Theme name |
lineNumbers | boolean | false | Show line numbers |
startLine | number | 1 | Starting line number |
highlightLines | number[] | [] | Lines to highlight |
wordWrap | boolean | false | Wrap long lines |
| Theme | Description |
|---|---|
monokai | Dark theme with vibrant colors |
dracula | Purple-tinted dark theme |
github | Light theme matching GitHub |
one-dark | Atom One Dark theme |
Visual progress indicators.
import {
ProgressBar,
PercentageColumn,
TimeElapsedColumn,
} from "terminal-richjs";
const bar = new ProgressBar(100, 75, {
width: 40,
completeStyle: "#61afef",
finishedStyle: "#50fa7b bold",
remainingStyle: "#3a3a3a dim",
completeChar: "ā",
remainingChar: "ā",
});
console.print(bar);
const pct = new PercentageColumn(0.75); // 75%
const elapsed = new TimeElapsedColumn(65000); // 1:05| Option | Type | Default | Description |
|---|---|---|---|
width | number | 40 | Bar width |
completeStyle | string | '#61afef' | Completed portion style |
finishedStyle | string | '#50fa7b bold' | Style at 100% |
remainingStyle | string | '#3a3a3a dim' | Remaining portion style |
pulse | boolean | false | Enable pulse animation |
completeChar | string | 'ā' | Completed character |
remainingChar | string | 'ā' | Remaining character |