Is it possible to set the width of a DataTable column? #4770
-
I have a 2 columns table. When the terminal screen is narrow, only one column is displayed because the first column contains some rows that can get pretty long. I want the two columns to use the space equally (50/50), and preferably each also have a maximum width that matches the content. This way if the screen is narrow I'll see the beginning of each of the columns, and if the screen is wide the gaps between the columns wouldn't be too big. Is it possible to do that? I'm not sure which CSS selectors I can play around with, if at all. Thank you very much! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
The cells/rows/columns in a The Perhaps you could handle the |
Beta Was this translation helpful? Give feedback.
The cells/rows/columns in a
DataTable
aren't widgets, so I'm afraid you won't find any solution using Textual's CSS.The
DataTable.add_column
method does have awidth
param, but that is limited to an absolute value in cells.Perhaps you could handle the
Resize
event to dynamically change the column widths, but it might be nice if theDataTable
provided some easier way of handling this!