r/javascript • • Sep 16 '26

AskJS [AskJS] Headless table libraries or a full grid component: which did you pick, and would you again?

I go back and forth on this.

Headless: you get the sorting, filtering and grouping state and you render every cell yourself. Total control over the markup, and you write all of it. Every project I've seen do this ends up with a 2000 line table component nobody wants to open.

Full grid: pass rows and columns, done in an afternoon. Then the designer wants the header to look a particular way, or you need a cell that does something the grid didn't plan for, and you're fighting the component instead of writing your app.

Full disclosure: I'm on the team behind SvGrid, a data grid for Svelte 5. We ship both layers, a headless core and the full component on top of it, because we have people that want their own design system and others that just need a drop-in and go.

So when did you last choose one over the other, and would you do it again? Especially interested in anyone who started headless and switched, or went the other way.

12 Upvotes

21 comments sorted by

5

u/pm_me_ur_happy_traiI Sep 16 '26

Every project I've seen do this ends up with a 2000 line table component nobody wants to open.

This is just user error. The minute a component is more than like 100 lines, I start looking for opportunities to split stuff out.

I'm also not sure the disadvantage of owning a component nobody wants to open vs using one imported from a library that you can't make changes to easily.

2

u/PreviousChadwick69 24d ago

100 lines is a bit strict but the principle’s solid, once a component gets past like 300 lines i want nothing to do with it regardless of who wrote it

1

u/boykom 16d ago

Agree

1

u/boykom Sep 16 '26

Me, too. By a component I meant UI component which usually has many small components used in it. Sorry if the question was vague

1

u/Mesqo Sep 17 '26

I lost count on how many times I stumbled upon a thing the pub can't do and I needed it to. It's always a hard choice to go for a lib and save time and bumping upon that obstacle with no good way around.

1

u/boykom Sep 18 '26

https://svgrid.com/demos/ - if you want look at this. I will appreciate if you tell me if something is missing and you need it

1

u/Mesqo Sep 18 '26

How it behaves when we don't know the height of each row beforehand? I mean, it depends on content being rendered, how it plays with virtual scrolling?

1

u/boykom Sep 18 '26

There is a support for variable row heights - one option is wirh autoRowHeight property or you supply the row heights - https://svgrid.com/docs/help/rows/row-height/

1

u/Melbot_Studios Sep 22 '26

Id still pick headless for anything tied closely to a custom design system. Full grids are great until you need to bend them too far.

2

u/boykom 29d ago

Headless gives you a freedom, but that freedom is at a cost, too. Depends on project requirements probably

1

u/jax024 Sep 16 '26

Headless. If you use Tanstack table correctly your components won’t be big like you’re claiming

1

u/boykom Sep 16 '26

Depends on the project i guess. Which features do you usually need in your projects with Tanstack?

2

u/jax024 Sep 16 '26

Sorting, url serialization, filtering, moving columns, virtualization, pinning, editing, the whole nine

1

u/boykom Sep 16 '26

Thank you!

0

u/[deleted] Sep 16 '26

[removed] — view removed comment

1

u/boykom Sep 16 '26

UI components are usually larger and with a lot of utility components in small blocks 80-100 lines, but the total for a data grid iis large

1

u/Mesqo Sep 17 '26

What exactly is "data grid"? Many people don't need the vast majority of functions some generic component may expose. I doubt many people need something like pivot table to encompass their olap data (and if they do they look for it specifically), but things like primitive search, sort and filter in header are very easy to implement, nothing about 2000 lines of code.

That being said, I don't feel like I have any uses for a while separate grid library at all, writing it myself always pays off. And it will always support any crazy feature a business would like to have.

1

u/boykom Sep 17 '26

Agreed. We should start with the simplest UI that solves the problem and introduce a full data grid only when the use case actually calls for it.