svelte-headless-table
svelte-headless-table copied to clipboard
Feature Request: Cell/Header Attributes
The createRender
function is nice for rendering full-blown components, sometimes all you need is a data-*
attribute or class
to get the cell where you want it. These attributes could be merged with the ones already provided by the library to spread onto the various elements.
Something along the lines of this:
table.column({
header: 'Type',
accessor: 'type',
+ cellAttrs: ({ value }) => ({
+ 'data-value': value,
+ 'data-button': true,
+ }),
+ headerAttrs: () => ({
+ 'data-whatever': 'whatever'
+ })
}),
Where the Attrs
takes the same params as the respective render properties, but expects a Record<string, unknown>
or similar.
If this is something you'd be willing to accept into the library, I'm more than happy to submit a PR - just want your blessing before spending the time @bryanmylee!
@huntabyte he seems to be pretty busy lately, but he answered and merged some of my PRs not long ago.
For the record, I've been using simple components like <Faded/>
or <Strong/>
for basic styling, and I would benefit from this update!
I'm just curious on his insights if this should be a plugin or part of the column definition!
I personally think a plugin would make sense as it would be tree shakable and the design of the plugin system is well adapted for this kind of functionality.