Skip to content

table dynamic column width based on text length#243

Open
codygulley wants to merge 1 commit intoyaronn:masterfrom
codygulley:dynamic-column-width
Open

table dynamic column width based on text length#243
codygulley wants to merge 1 commit intoyaronn:masterfrom
codygulley:dynamic-column-width

Conversation

@codygulley
Copy link
Copy Markdown

@codygulley codygulley commented Nov 25, 2023

This contribution provides the following feature:

  • default behavior is to make column as wide as the longest text in the column (headers included)
  • columnWidth option is no longer mandatory
  • if columnWidth is omitted it will calculate the width based on the length of text in the column (headers and data)
  • if columnWidth is defined for the column index in the columnWidth array it will use that value, if it is undefined or null it will calculate the value.
Screenshot 2023-11-25 at 2 45 58 AM

cc: @lirantal @yaronn

@codygulley codygulley changed the title dynamic column width based on text length - optimized to only run cal… table dynamic column width based on text length Nov 25, 2023
@codygulley
Copy link
Copy Markdown
Author

Can I get reviews on this @yaronn ?

codemeasandwich pushed a commit to codemeasandwich/CliUI that referenced this pull request Feb 2, 2026
- Make columnWidth optional - auto-calculates from headers/data
- Calculate max width per column before formatting rows
- Preserve explicit columnWidth if provided (backwards compatible)
- Integrates blessed-contrib PR yaronn#243
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

Successfully merging this pull request may close these issues.

1 participant