You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Expand typing for Title field in Table object #4172
When building tables in a CLI program I am working on, I have varying sized tables that are smaller than the console width. I was using the Rule object as a separator between them, but I also had a Text object centered in the middle of the Rule object as sort of a title. The issue came in that the Rule was spanning the entire width of the console instead of just the Table's width. I then passed the Rule in for the title field which then restricted the Rule to the Table's width. This worked cleaning except for the typing. The title field is currently set to Union[str, Text], optional and I think it would benefit from a less strict typing.
Suggested Change
Update the Title arg in the Table Class with a more open typing that accepts more than just str and Text objects.
Benefits
There are currently a couple of other ways I can think of handling this. One would be putting both the Rule and the Table in a Table.grid object. Another way is determining the width of the Table and then building a Text object the same size. Both seem cumbersome and overall would be more cleanly solved by just passing a Rule in for the title of a Table.
Hi! I have prepared a fix for this issue with updating Table.title and Table.caption types to RenderableType, along with passing unit tests. Since repository PR interactions are currently limited to collaborators, my branch is available on my fork here: https://github.com/Jyotish08/rich/tree/fix-table-title-typing. Please let me know if you'd like me to open a PR when interactions reopen!
Activity
krishnaverma001 commentedon Jun 19, 2026
Hi! I've prepared a fix for this issue. My branch is available at:
https://github.com/krishnaverma001/rich/tree/fix-table-title-typing
Changes include:
Table.titleandTable.captiontyping fromTextTypetoRenderableTypetest_rule_in_table.pyandtest_table.pyThis allows users to pass
Rule,Panel, or any renderable as table titles.Could someone please review my changes or add me as a collaborator so I can open the PR?
Thank you!
let table title and caption be any renderable
let table title and caption be any renderable
Jyotish08 commentedon Jul 28, 2026
Hi! I have prepared a fix for this issue with updating Table.title and Table.caption types to RenderableType, along with passing unit tests. Since repository PR interactions are currently limited to collaborators, my branch is available on my fork here: https://github.com/Jyotish08/rich/tree/fix-table-title-typing. Please let me know if you'd like me to open a PR when interactions reopen!