# cli-tableau

> Pretty unicode tables for the CLI

Latest version **2.0.1** (published 2020-06-15) · 0 weekly downloads

## Install

```sh
npm install cli-tableau
pnpm add cli-tableau
yarn add cli-tableau
bun add cli-tableau
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.1 |
| Published | 2020-06-15 |
| First published | 2020-04-19 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=8.10.0 |
| Dependencies | 1 |
| Unpacked size | 16.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 34 |
| Author | Guillermo Rauch |
| Maintainers | tknew |
| Keywords | cli, colors, table |

## Links

- npm: https://www.npmjs.com/package/cli-tableau
- Repository: https://github.com/Keymetrics/cli-table
- Homepage: https://github.com/Keymetrics/cli-table#readme
- Issues: https://github.com/Keymetrics/cli-table/issues
- npm.io page: https://npm.io/package/cli-tableau

## Dependencies (1)

- [chalk](https://npm.io/package/chalk.md) 3.0.0

## Alternatives

- [@lexical/table](https://npm.io/package/@lexical/table.md) — 3.0M weekly downloads
- [mantine-datatable](https://npm.io/package/mantine-datatable.md) — 98.2K weekly downloads
- [react-native-collapsible-tab-view](https://npm.io/package/react-native-collapsible-tab-view.md) — 70.6K weekly downloads
- [@handsontable/vue3](https://npm.io/package/@handsontable/vue3.md) — 16.1K weekly downloads
- [vuewordcloud](https://npm.io/package/vuewordcloud.md) — 7.2K weekly downloads

## Recent versions

- 2.0.1 (latest) — 2020-06-15
- 2.0.0 — 2020-04-19

## README

# cli tableau

<a href="https://travis-ci.org/github/keymetrics/cli-tableau" title="PM2 Tests">
  <img src="https://travis-ci.org/keymetrics/cli-tableau.svg?branch=master" alt="Build Status"/>
</a>


### Horizontal Tables
```javascript
var Table = require('cli-tableau');

var table = new Table({
    head: ['TH 1 label', 'TH 2 label'],
    colWidths: [100, 200],
    borders: false
});

table.push(
    ['First value', 'Second value'],
    ['First value', 'Second value']
);

console.log(table.toString());
```

### Vertical Tables

```javascript
var Table = require('cli-tableau');
var table = new Table();

table.push(
    { 'Some key': 'Some value' },
    { 'Another key': 'Another value' }
);

console.log(table.toString());
```

### Cross Tables
Cross tables are very similar to vertical tables, with two key differences:

1. They require a `head` setting when instantiated that has an empty string as the first header
2. The individual rows take the general form of { "Header": ["Row", "Values"] }

```javascript
var Table = require('cli-tableau');
var table = new Table({ head: ["", "Top Header 1", "Top Header 2"] });

table.push(
    { 'Left Header 1': ['Value Row 1 Col 1', 'Value Row 1 Col 2'] },
    { 'Left Header 2': ['Value Row 2 Col 1', 'Value Row 2 Col 2'] }
);

console.log(table.toString());
```

### Custom styles

The ```chars``` property controls how the table is drawn:
```javascript
var table = new Table({
  chars: {
    'top': '═' , 'top-mid': '╤' , 'top-left': '╔' , 'top-right': '╗',
    'bottom': '═' , 'bottom-mid': '╧' , 'bottom-left': '╚' , 'bottom-right': '╝',
    'left': '║' , 'left-mid': '╟' , 'mid': '─' , 'mid-mid': '┼',
    'right': '║' , 'right-mid': '╢' , 'middle': '│'
  }
});

table.push(
    ['foo', 'bar', 'baz'],
    ['frob', 'bar', 'quuz']
);

console.log(table.toString());
// Outputs:
//
//╔══════╤═════╤══════╗
//║ foo  │ bar │ baz  ║
//╟──────┼─────┼──────╢
//║ frob │ bar │ quuz ║
//╚══════╧═════╧══════╝
```

Empty decoration lines will be skipped, to avoid vertical separator rows just
set the 'mid', 'left-mid', 'mid-mid', 'right-mid' to the empty string:
```javascript
var table = new Table({ chars: {'mid': '', 'left-mid': '', 'mid-mid': '', 'right-mid': ''} });
table.push(
    ['foo', 'bar', 'baz'],
    ['frobnicate', 'bar', 'quuz']
);

console.log(table.toString());
// Outputs: (note the lack of the horizontal line between rows)
//┌────────────┬─────┬──────┐
//│ foo        │ bar │ baz  │
//│ frobnicate │ bar │ quuz │
//└────────────┴─────┴──────┘
```

By setting all chars to empty with the exception of 'middle' being set to a
single space and by setting padding to zero, it's possible to get the most
compact layout with no decorations:
```javascript
var table = new Table({
  chars: {
    'top': '' , 'top-mid': '' , 'top-left': '' , 'top-right': '',
    'bottom': '' , 'bottom-mid': '' , 'bottom-left': '' , 'bottom-right': '',
    'left': '' , 'left-mid': '' , 'mid': '' , 'mid-mid': '',
    'right': '' , 'right-mid': '' , 'middle': ' '
  },
  style: { 'padding-left': 0, 'padding-right': 0 }
});

table.push(
    ['foo', 'bar', 'baz'],
    ['frobnicate', 'bar', 'quuz']
);

console.log(table.toString());
// Outputs:
//foo        bar baz
//frobnicate bar quuz
```

## Credits

- Guillermo Rauch &lt;guillermo@learnboost.com&gt; ([Guille](http://github.com/guille))

---
_Source: https://npm.io/package/cli-tableau · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
