charmbracelet / charmbracelet/bubbles

table.WithWidth doesn't work properly

Open
#696 3 comments 1 reaction 0 assignees View on GitHub
bug table
Dominant language
Go
Stars
8.9k
Forks
457
Avg merge
1d 18h
Merged PRs (30d)
5

Description

**Describe the bug**
Setting it to almost any value causes the table to be rendered in ways you probably didn't expect.

**Setup**
Please complete the following information along with version numbers, if applicable.
- OS [e.g. Ubuntu, macOS] any
- Shell [e.g. zsh, fish] any
- Terminal Emulator [e.g. kitty, iterm] any
- Terminal Multiplexer [e.g. tmux] any
- Locale [e.g. en_US.UTF-8, zh_CN.UTF-8, etc.] any

**To Reproduce**
Steps to reproduce the behavior:
1. You can copy the table example from `bubbletea`
2. Add a `table.WithWidth` [here](https://github.com/charmbracelet/bubbletea/blob/d67033479573c91fc4a0e450fe84bbd0d6db6c5d/examples/table/main.go#L164)
3. Run it
4. See it looks weid

**Source Code**
https://github.com/charmbracelet/bubbletea/blob/d67033479573c91fc4a0e450fe84bbd0d6db6c5d/examples/table/main.go#L164

**Expected behavior**
I'm not sure what it should do, but I think what it's doing now is wrong.

**Screenshots**
![CleanShot 2025-01-07 at 13 01 24@2x](https://github.com/user-attachments/assets/e26dfc23-89f7-428d-b290-c50d1cdb1614)
![CleanShot 2025-01-07 at 13 01 41@2x](https://github.com/user-attachments/assets/f95517da-740a-4f8d-859a-938685c96fc4)

**Additional context**
If you remove the widths of the headers, the table is rendered empty. Not sure if intended, weird anyway.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.