HTML table columns are a pain, as we all know. The default is they expand to fill the content, regardless of width styling. This is often not what we want. The recommendations for fixing column widths that I could find (and here and there) recommend setting table-layout: fixed
, and that
If you change this to fixed, the table and column widths are set by the widths of table and col elements or by the width of the first row of cells.
Emphasis mine. Here is the dilemma: the first row of cells is thead > tr > th
, and customizing those cells is difficult in this library. (It's easy enough to set widths of the tbody
row cells, but the browser ignores these.) Essentially, it is impossible to set fixed column widths using this library without overriding your config.customizations.thead
function. And yet, it does seem like this is a basic feature that should be supported without quite so much pain.
My thought for an interface is
myConfig =
Table.configWithWidths
{ toId = .id
, toMsg = SetTableState
, columns =
[ (myColumn1, "25%"), (myColumn2, "15%"), (myColumn3, "60%")
]
}
where:
configWithWidths :
{ toId : data -> String
, toMsg : State -> msg
, columns : List (Column data msg, String)
}
-> Config data msg
and then threading that through a customizations.thead
function that sets the width on the th
elements. (Or instead of untyped widths, have unit types for px
, %
, em
, etc. similar to elm-css.)
What do you think?
EDIT: I'd be happy to open a PR. I have it working externally.