$ Table
static output
Formatted data tables with headers, auto-sized columns, alternating row colors, and Unicode box-drawing borders.
# Preview
table demo
┌───────────┬──────────┬─────────┐ │ Name │ Role │ Status │ ├───────────┼──────────┼─────────┤ │ Alice │ Engineer │ Active │ │ Bob │ Designer │ Away │ │ Charlie │ Manager │ Active │ └───────────┴──────────┴─────────┘
# Usage
example.ts
import { Table, fg, colorize } from "@vr_patel/tui";
const table = new Table({
headers: ["Name", "Role", "Status"],
rows: [
["Alice", "Engineer", colorize("Active", fg.green)],
["Bob", "Designer", colorize("Away", fg.yellow)],
["Charlie", "Manager", colorize("Active", fg.green)],
],
alternateRowColor: true,
});
console.log(table.render());# API
| Prop | Type | Default | Description |
|---|---|---|---|
| headers | string[] | required | Column header labels |
| rows | string[][] | required | 2D array of cell values |
| borderColor | string | fg.gray | Color for table borders |
| headerColor | string | fg.cyan + bold | Color for header row |
| alternateRowColor | boolean | true | Alternate row shading |
| padding | number | 1 | Cell padding in spaces |