cli-table3 icon indicating copy to clipboard operation
cli-table3 copied to clipboard

Border Color

Open 0xJWLabs opened this issue 1 year ago • 4 comments

Is there a way to change border color using hex? Thanks!

0xJWLabs avatar Aug 24 '24 18:08 0xJWLabs

Try something like:

const Table = require('cli-table3');

const table = new Table({ style: { border: ['blue'] } });
table.push(['foo']);

console.log(table.toString());

Produces: image

This isn't well documented because of how the documentation is generated (without color). The documentation shows removing the default grey border, but doesn't show setting a color.

speedytwenty avatar Aug 25 '24 05:08 speedytwenty

"using hex"

I apologize, I overlooked this part of your question. I see now that setting a hex color does not work.

I don't see an obvious way. It would require customizing the "border chars" somewhat like: https://github.com/cli-table/cli-table3/blob/master/basic-usage.md#stylize-the-table-with-custom-border-characters

speedytwenty avatar Aug 25 '24 05:08 speedytwenty

@speedytwenty I think using chalk or ansis isn’t really a good way right? since i saw there’s somehow a leftover of the ansi like let’s say

————;30;60m

0xJWLabs avatar Aug 26 '24 00:08 0xJWLabs

Hello @0xJWLabs,

I'm the author of ansis.

In the #354 PR I have added the support for hex code to allow using a truecolor in a table.

The proposal for new syntax:

style: { 
  border: ['hex(#FFD700)'], 
  head: ['hex(#FFA500)', 'bgHex(#3d239d)']
}

webdiscus avatar Feb 09 '25 00:02 webdiscus