Usage
Introduction on How to use Lens Datatable.
Usage
The Datatable
component is a powerful abstraction over TanStack Table, designed to render data views based on backend configurations while offering flexibility for UI customization, interactions, and actions.
Basic Example
The simplest way to use the Datatable
is by passing a viewId
. This ID links the component to a predefined configuration (columns, filters, etc.) typically managed on the backend.
Enabling Selection
You can enable row selection by passing the selectedItems
array and the onSelect
callback. This allows external control over selected rows:
Adding Row Actions
To add contextual actions for each row (like Edit, Delete, View), use the rowActions
prop. This function receives the row object and returns a list of actions:
Each action supports label
, icon
, and onClick
.
Styling the Table
The classNames
prop lets you override styles for different parts of the table such as the table, headers, rows, and cells.
This enables full control over the table’s appearance using Tailwind classes (or any CSS class system).
Disable Column Resizing
If you want a simpler layout without column resizing, just set disableResizing
to true
:
That's it for getting started!
Next, check out the Props Reference or explore how to customize Styling further.