Skip to main content

Coloring

Coloring#

You can put color as either entire Row or entire column

const { Table } = require("console-table-printer");
const p = new Table({  columns: [    { name: "index", alignment: "left", color: "yellow" }, // column coloring    { name: "text", alignment: "right" },  ],});
p.addRow({ index: 1, text: "red wine", value: 10.212 }, { color: "green" }); // row coloring
p.addRow({ index: 2, text: "green gemuse", value: 20.0 });p.addRow(  { index: 3, text: "gelb bananen", value: 100, is_priority_today: "Y" },  { color: "yellow" });p.addRow(  { index: 3, text: "rosa hemd wie immer", value: 100 },  { color: "cyan" });p.printTable();
Screenshot

Batch Row coloring#

const { printTable, Table } = require("console-table-printer");
const p = new Table();
p.addRows(  [    // adding multiple rows are possible    { index: 3, text: "green color text1", value: 100 },    { index: 4, text: "green color text2", value: 300 },  ],  { color: "green" } // multiple rows sharing same properties);
// printp.printTable();
Screenshot

possible color values for rows/columns#

  • red
  • green
  • yellow
  • white
  • blue
  • magenta
  • cyan
  • crimson
  • white_bold