-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature Request: Table Component #229
Comments
Check the typography page, there is a table in there. |
While it's true there is a table "example" in the Typography that looks like this: export function TypographyTable() {
return (
<div className="my-6 w-full overflow-y-auto">
<table className="w-full">
<thead>
<tr className="m-0 border-t p-0 even:bg-muted">
<th className="border px-4 py-2 text-left font-bold [&[align=center]]:text-center [&[align=right]]:text-right">
King's Treasury
</th>
<th className="border px-4 py-2 text-left font-bold [&[align=center]]:text-center [&[align=right]]:text-right">
People's happiness
</th>
</tr>
</thead>
<tbody>
<tr className="m-0 border-t p-0 even:bg-muted">
<td className="border px-4 py-2 text-left [&[align=center]]:text-center [&[align=right]]:text-right">
Empty
</td>
<td className="border px-4 py-2 text-left [&[align=center]]:text-center [&[align=right]]:text-right">
Overflowing
</td>
</tr>
<tr className="m-0 border-t p-0 even:bg-muted">
<td className="border px-4 py-2 text-left [&[align=center]]:text-center [&[align=right]]:text-right">
Modest
</td>
<td className="border px-4 py-2 text-left [&[align=center]]:text-center [&[align=right]]:text-right">
Satisfied
</td>
</tr>
<tr className="m-0 border-t p-0 even:bg-muted">
<td className="border px-4 py-2 text-left [&[align=center]]:text-center [&[align=right]]:text-right">
Full
</td>
<td className="border px-4 py-2 text-left [&[align=center]]:text-center [&[align=right]]:text-right">
Ecstatic
</td>
</tr>
</tbody>
</table>
</div>
)
} But probably if meant to be a "ready to use component", it will be like this: export function TableExample() {
return (
<div>
<Table>
<TableHeader>
<TableRow>
<TableHead>King's Treasury</TableHead>
<TableHead>People's happiness</TableHead>
</TableRow>
</TableHeader>
<TableBody>
<TableRow>
<TableData>Empty</TableData>
<TableData>Overflowing</TableData>
</TableRow>
<TableRow>
<TableData>Modest</TableData>
<TableData>Satisfied</TableData>
</TableRow>
<TableRow>
<TableData>Full</TableData>
<TableData>Ecstatic</TableData>
</TableRow>
</TableBody>
</Table>
</div>
);
} References/inspirations: |
Indeed, a Table component offers more advanced features such as column sorting, pagination, and possibly the ability to use custom Row/Column Templates with the items passed as parameters, making it distinct from the simple table example in the docs. +1 |
@tcortega It can also starts simple with only the styling first, without any particular interactive feature. Like what Flowbite has here: https://flowbite.com/docs/components/tables If need more functionality (not just a styling) then will need to integrate with existing table library such as TanStack Table: https://tanstack.com/table/v8 |
I'll use TanStack Table in the meanwhile, didn't know about it, thankssssssss |
@tcortega Sure thing, you're welcooome |
Hey there! If you're searching for something a bit more advanced, you might enjoy exploring Material UI Data Grid: https://mui.com/x/react-data-grid/ this is what i use for now but having a hard time customizing it to fit the UI design, It would be fantastic to see it integrated as a feature in the future! 😊 |
+1 a table component that would allow filtering/pagination/sorting would be very useful |
I'd love to see that too! I've already combined some of the table styles from the typography page with tanstack table. Has anyone some ideas, which parts of the tanstack table api a component should cover? I'd PR one. |
I think this ends up being a pretty personal answer, but, I'd pretty much just use filtering support (global/custom filtering, not filtering per column), column sorting, pagination and that's pretty much I guess? |
There is a PR related to this: #248 feat(Table): Add Table component |
I'd say that this table is pretty solid but also too simple |
Yeah, @shadcn said:
And @multiwebinc said:
|
As an alternative, I would also like to recommend Adobe's React Aria, which has an accessibility-first philosophy and would probably be a better fit for Radix. |
Just realized this is also nice. Probably at the moment if people need a Table component depending on the use cases or complexity, here are the options:
Note: This is not just about for table component in shadcn UI case, rather for general answers. |
To be honest, I don't see the necessity of using intermediate tables like React Aria's or MUI's. TanStack already offers accessibility and is extremely user-friendly. It provides optional features that work seamlessly across various browsers. I've built and tested it using the same style as shadcn. Typically, there are two scenarios: displaying a small amount of data in a tabular format, or displaying a small or large dataset with filtering, sorting, and pagination capabilities for users. Given that React Aria's table lacks pagination, I find the middle option redundant. |
@tcortega Yes, you're correct. To clarify, actually, for my above list, I was not specifically talking about table components in this case only. But rather some options people can choose at the moment. Therefore, the necessity will depend on the person needing the components. So it depends. Also, I see that currently in existing PR, #248 by @multiwebinc, it leans towards the simple table first, just the UI. And it's already fine. In that PR, @shadcn said:
|
@tcortega Actually TanStack does not offer accessibility (straight from its author), so if we want to follow the same philosophy as Radix, we would need to code accessibility ourselves. I have no idea what that would entail, if it's just a few lines of code, or hundreds. |
Whoa and what just shipped is also the Data Table with TanStack Table https://ui.shadcn.com/examples/tasks |
No description provided.
The text was updated successfully, but these errors were encountered: