Example Tables
We've put together a collection of Next.js Reusable Table Component examples to help you get started.
Basic Table
This is a simple example using default styles with columns, data, and no custom styling or action dropdowns.
Name | Role | Edit, Delete | ||
---|---|---|---|---|
John Doe | john@example.com | Admin |
Custom Styles
Here, you can pass custom class names using the customClassNames
prop to override the default styles. Also disable the default dark mode style applied by setting enableDarkMode
to false.
Name | Role | |
---|---|---|
John Doe | john@example.com | Admin |
Jane Doe | jane@example.com | User |
Table with Pagination
If you want to use a pagination component, you can pass it as the paginationComponent prop.
Name | Role | |
---|---|---|
John Doe | john@example.com | Admin |
Jane Doe | jane@example.com | User |
Custom Rows and Actions
This is an example where the table displays custom rows, with the last column having a custom action button. You can use the renderRow function to customize how each row is rendered and place a custom action button for the last item.
ID | Name | Role | Actions | |
---|---|---|---|---|
1 | John Doe | john@example.com | Admin | |
2 | Jane Doe | jane@example.com | User | |
3 | Bob Smith | bob@example.com | Editor |
URL, Date/Time, Arrays
This is an example where I’m using the default TableComponent and passing a data object with a URL, date, and an array of strings. The TableComponent will automatically handle rendering for these data types based on the logic already present in the component.
ID | Website | Created At | Roles |
---|---|---|---|
1 | https://example.com | Sep 20, 2023, 02:12 PM | AdminEditorViewer |
2 | https://another-site.com | Aug 15, 2023, 10:05 AM | UserModerator |
3 | https://yetanother.com | Jul 1, 2023, 06:20 PM | GuestContributor |
Loading State
You can set the loading prop to true to show a shimmer in the table.
| | | | |
---|---|---|---|---|
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
Default Row Clicking
This example shows how to use the rowOnClick
prop in your TableComponent. When you click on a row, it will trigger a function that can display more details about the clicked item
Name | Role | |
---|---|---|
John Doe | john@example.com | Admin |
Jane Doe | jane@example.com | User |
Bob Smith | bob@example.com | Editor |