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
If a design requires some table columns to be larger than others, specification of a size on the "first table row" (typically, one or more <th> elements) is required. While it is possible to provide a custom headerComponent to each sized column to resolve this issue, creation of a component to be able to set a class seems like overkill. Rather, it would be easier to simply pass a class on the <TableColumn> component and have the class be propagated to the <th> element in the <TableHeader>.
Suggested Solution
I believe this can be resolved simply by:
Pulling an explicit className prop out of the column prop in the TableHeader definition.
Passing the resulting class to the rendered <th> element's className.
@mwislek I'd accept a PR for this! I think id would also be an acceptable prop to pass down, since class may not necessarily be the right level of abstraction for a one-off column.
Your syntax is a little off in your suggestion, though.
The order which className is passed in doesn't matter, it just needs to be passed in directly, not in the object syntax (classnames takes the key for a truthy value). Typically, I like to pass it as the first arg because I think it reads nicely, but I'm not strongly coupled to that.
Feature Description
By default in the client template, tables use
table-layout: fixed
. By default, this configuration makes all columns an equal size (see: https://css-tricks.com/almanac/properties/t/table-layout/).If a design requires some table columns to be larger than others, specification of a size on the "first table row" (typically, one or more
<th>
elements) is required. While it is possible to provide a customheaderComponent
to each sized column to resolve this issue, creation of a component to be able to set a class seems like overkill. Rather, it would be easier to simply pass a class on the<TableColumn>
component and have the class be propagated to the<th>
element in the<TableHeader>
.Suggested Solution
I believe this can be resolved simply by:
className
prop out of thecolumn
prop in theTableHeader
definition.<th>
element'sclassName
.That is:
Alternatives Considered / Existing Workarounds
Creation of a specific header component instance for each column on which a size specification is required.
Additional Context
The text was updated successfully, but these errors were encountered: