Skip to content

Border Color #352

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
0xJWLabs opened this issue Aug 24, 2024 · 4 comments
Open

Border Color #352

0xJWLabs opened this issue Aug 24, 2024 · 4 comments

Comments

@0xJWLabs
Copy link

0xJWLabs commented Aug 24, 2024

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

@speedytwenty
Copy link
Collaborator

speedytwenty commented Aug 25, 2024

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
Copy link
Collaborator

"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

@0xJWLabs
Copy link
Author

@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

webdiscus added a commit to webdiscus/cli-table3 that referenced this issue Feb 8, 2025
- replace @colors/colors with smaller, fater ansis which supports truecolor
- add a syntax for using hex color in style option
- add doumentation to the README how to use colors in tables
- add tests for using colors
- add missing test coverage script to package.json
@webdiscus
Copy link

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)']
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants