Data
TwDataTable
TwDataTable is a Blazor data table component with pagination, search, sortable columns and custom row classes for displaying structured data.
Last updated
Basic data table with pagination
A feature-rich data table with pagination and search functionality.
| Product | Category | Price | Stock |
|---|---|---|---|
| Apple MacBook Pro 17" | Laptop | £2,999.00 | 15 |
| Microsoft Surface Pro | Laptop | £1,999.00 | 8 |
| Magic Mouse 2 | Accessories | £99.00 | 50 |
| Apple Watch Series 9 | Wearables | £499.00 | 25 |
| iPad Air | Tablet | £799.00 | 5 |
Searchable data table
Data table with search functionality to filter results.
| Product | Category | Price | Stock |
|---|---|---|---|
| Apple MacBook Pro 17" | Laptop | £2,999.00 | 15 |
| Microsoft Surface Pro | Laptop | £1,999.00 | 8 |
| Magic Mouse 2 | Accessories | £99.00 | 50 |
| Apple Watch Series 9 | Wearables | £499.00 | 25 |
| iPad Air | Tablet | £799.00 | 5 |
| Samsung Galaxy S24 | Phone | £1,199.00 | 30 |
| Sony WH-1000XM5 | Accessories | £399.00 | 12 |
| Dell XPS 15 | Laptop | £2,199.00 | 18 |
| Google Pixel 8 Pro | Phone | £999.00 | 22 |
| AirPods Pro | Accessories | £249.00 | 40 |
Data table without pagination
Display all data without pagination controls.
| Name | Department | Role |
|---|---|---|
| John Doe | Engineering | Developer |
| Jane Smith | Product | Designer |
| Bob Johnson | Operations | Manager |
| Alice Williams | Engineering | Developer |
| Charlie Brown | Quality | QA Engineer |
Custom row classes
Data table with custom row styling based on conditions.
| Product | Category | Price | Stock |
|---|---|---|---|
| Apple MacBook Pro 17" | Laptop | £2,999.00 | 15 |
| Microsoft Surface Pro | Laptop | £1,999.00 | 8 (Low Stock) |
| Magic Mouse 2 | Accessories | £99.00 | 50 |
| Apple Watch Series 9 | Wearables | £499.00 | 25 |
| iPad Air | Tablet | £799.00 | 5 (Low Stock) |
Sortable data table with columns
Data table with per-column sortability. Click column headers to sort. Some columns are sortable (with icons), others are not.
Product Name | Category | Price | Stock |
|---|---|---|---|
| Apple MacBook Pro 17" | Laptop | £2,999.00 | 15 |
| Microsoft Surface Pro | Laptop | £1,999.00 | 8 (Low Stock) |
| Magic Mouse 2 | Accessories | £99.00 | 50 |
| Apple Watch Series 9 | Wearables | £499.00 | 25 |
| iPad Air | Tablet | £799.00 | 5 (Low Stock) |
| Samsung Galaxy S24 | Phone | £1,199.00 | 30 |
| Sony WH-1000XM5 | Accessories | £399.00 | 12 |
| Dell XPS 15 | Laptop | £2,199.00 | 18 |
| Google Pixel 8 Pro | Phone | £999.00 | 22 |
| AirPods Pro | Accessories | £249.00 | 40 |
Column widths and fixed layout
Give a column a
Width to size it. Any CSS length works, such as 40% or 8rem, and columns without a width share the rest. Add FixedLayout so the columns keep their widths as you page, sort and search, instead of jumping to fit each page's content. With TableHeader and TableRow, pass a ColumnGroup of TwTableColumn elements instead, as on TwTable.
Product Name | Category | Price |
|---|---|---|
| Apple MacBook Pro 17" | Laptop | £2,999.00 |
| Microsoft Surface Pro | Laptop | £1,999.00 |
| Magic Mouse 2 | Accessories | £99.00 |
| Apple Watch Series 9 | Wearables | £499.00 |
| iPad Air | Tablet | £799.00 |
Filtering columns
Set
Filterable on a column and its header gains a filter button. It opens a filter with up to two conditions, joined with And or Or, then Filter applies them and Clear removes them. The conditions and the value field suit the column's values: text conditions such as Contains and Starts with, comparisons such as Is greater than for numbers and dates, and a list for true or false values and enums. Set FilterType when the type cannot be worked out, such as before an ItemsProvider has loaded any rows, and FilterOperators to choose the conditions on offer. Filters are saved with the table's state, sent to an ItemsProvider in Filters, and announced with the number of rows they leave.
Product Name
| Category
| Price
| Stock
|
|---|---|---|---|
| Apple MacBook Pro 17" | Laptop | £2,999.00 | 15 |
| Microsoft Surface Pro | Laptop | £1,999.00 | 8 |
| Magic Mouse 2 | Accessories | £99.00 | 50 |
| Apple Watch Series 9 | Wearables | £499.00 | 25 |
| iPad Air | Tablet | £799.00 | 5 |
Resizable columns
Set
ResizableColumns and every column's border becomes a resize handle, from TwTable. Drag it, or focus it with Tab and press Arrow Left or Arrow Right, holding Shift for bigger steps. Screen readers hear each border as "Resize Price" with the column's width. The widths are saved with the table's state. Resizable = false keeps a column at its width.
Product Name | Category | Price | Stock |
|---|---|---|---|
| Apple MacBook Pro 17" | Laptop | £2,999.00 | 15 |
| Microsoft Surface Pro | Laptop | £1,999.00 | 8 (Low Stock) |
| Magic Mouse 2 | Accessories | £99.00 | 50 |
| Apple Watch Series 9 | Wearables | £499.00 | 25 |
| iPad Air | Tablet | £799.00 | 5 (Low Stock) |
RAZOR
<TwDataTable TItem="Product"
Id="resizable-columns-table"
Items="@products"
Columns="@_productColumns"
ResizableColumns
RowsPerPage="5"
AriaLabel="Products with resizable columns" />Grouping rows
Set
Groupable on the columns people can group by, and a Group by list appears above the table. GroupBy picks the grouping the table starts with. Each group sits under a header row with a button that expands or collapses it, and Expand all groups and Collapse all groups work on every group at once. Rows keep the table's sort inside each group. A page that starts part way through a group repeats its header. Use GroupHeaderTemplate to add a summary to each header, such as a total.
Product Name | Category | Price | Stock level |
|---|---|---|---|
Stock value £19,698 | |||
| Magic Mouse 2 | Accessories | £99.00 | In stock |
| Sony WH-1000XM5 | Accessories | £399.00 | In stock |
| AirPods Pro | Accessories | £249.00 | In stock |
Stock value £22,491 | |||
| Canon EOS R6 | Camera | £2,499.00 | Low |
Stock value £5,215 | |||
| Kindle Paperwhite | E-Reader | £149.00 | In stock |
Stock value £6,584 | |||
| Nintendo Switch | Gaming | £299.00 | Low |
Virtualizing thousands of rows
Set
EnableVirtualization and the table renders only the rows scrolled into view, so it stays fast with tens of thousands of rows. The rows scroll inside the table instead of being paged, and the header stays in view. Change the height with Height. Keep each row to one line, about ItemSize pixels tall. Screen readers are told the full row count and each row's place, so they still read "row 5000 of 10000". Sorting, searching, filtering, the column menu and grouping all work as before.
Order | Customer | Placed | Total |
|---|
Loading rows from a server
For data that is too big to load at once, give the table an
ItemsProvider in place of Items. The table asks it for one page at a time, passing the sort, search and column filters, so your database or API does the work and returns just those rows with the total count. Combine it with EnableVirtualization to load rows as they scroll into view. While rows load the table is marked busy, and the search result count is announced once they arrive. Call RefreshDataAsync after the data changes elsewhere.
Order | Customer | Placed | Total |
|---|---|---|---|
| Loading… | |||
Editing rows
Set
Editable to add an Actions column with an Edit button on each row. Editing turns the row's Editable columns into editors that match their values: a text field, a number field, a checkbox, a date picker or a list for an enum. Give a column an EditTemplate for any other editor. Save runs each column's Validator, marks any field that needs fixing and moves focus to it. Once every value is fine, each ValueSetter writes its value to the row and RowSaved is raised with the old and new values, ready to send to your API. Escape or Cancel leaves the row as it was, and focus goes back to the row's Edit button.
Product Name | Category | Price | Stock | Actions |
|---|---|---|---|---|
| Kettle | Kitchen | 30 | 14 | |
| Armchair | Furniture | 250 | 3 | |
| Desk lamp | Lighting | 45 | 22 | |
| Blender | Kitchen | 60 | 8 |
Exporting to CSV and Excel
Set
Exportable to add Export CSV and Export Excel buttons. An export holds the columns on screen in their current order, and by default every row that matches the search in its current sort, across all pages. Change that with ExportScope, or pick the buttons with ExportFormats. The Excel file keeps numbers, dates and true or false values as their own types, so they can be summed and filtered. Give a column an ExportFormatter to write a different value from the one on screen, or set Exportable = false to leave it out. Text that a spreadsheet would run as a formula is escaped.
Product Name | Category | Price | Stock |
|---|---|---|---|
| Apple MacBook Pro 17" | Laptop | £2,999.00 | 15 |
| Microsoft Surface Pro | Laptop | £1,999.00 | 8 |
| Magic Mouse 2 | Accessories | £99.00 | 50 |
| Apple Watch Series 9 | Wearables | £499.00 | 25 |
| iPad Air | Tablet | £799.00 | 5 |
To build the file yourself, call GetCsv or GetExcel on the table, or use TwDataTableExport with any rows and columns, for example to send a report from the server.
CSHARP
byte[] workbook = TwDataTableExport.ToExcel(orders, columns, sheetName: "Orders");
string csv = TwDataTableExport.ToCsv(orders, columns);Saving the table's state
Give the table a
StateStorageKey and it remembers its sort, search, page, page size and columns in the browser, so it comes back the way the person left it. Sort or hide a column below, then reload the page. ResetStateAsync puts it back to how the parameters define it.
Product Name | Category | Price |
|---|---|---|
| Apple MacBook Pro 17" | Laptop | £2,999.00 |
| Microsoft Surface Pro | Laptop | £1,999.00 |
| Magic Mouse 2 | Accessories | £99.00 |
| Apple Watch Series 9 | Wearables | £499.00 |
| iPad Air | Tablet | £799.00 |
Managing the state yourself
To keep the state somewhere else, such as a user's profile or the page address, bind
@bind-State. The table raises a new TwDataTableState after every change, and restores whichever state you pass in. It is made of plain values, so it serializes to JSON as it is. Columns are matched by Name, so a saved state survives columns being added or removed.
Product Name | Category | Price | Stock |
|---|---|---|---|
| Apple MacBook Pro 17" | Laptop | £2,999.00 | 15 |
| Microsoft Surface Pro | Laptop | £1,999.00 | 8 (Low Stock) |
| Magic Mouse 2 | Accessories | £99.00 | 50 |
| Apple Watch Series 9 | Wearables | £499.00 | 25 |
| iPad Air | Tablet | £799.00 | 5 (Low Stock) |
The current state:
JSON
Sort, search or change page to see the state.Theme configuration
Styling is controlled by
TwBlazorTheme.Components (a TwTableTheme), configured via the
AddTwBlazor() options callback described on the Get Started page.
Every property is a set of Tailwind classes, so changes are picked up by your own Tailwind build.
Inherited from TwTable - this component reuses that theme rather than defining its own.
| Property | Type | Controls |
|---|---|---|
Wrapper |
string | |
ContainerClip |
string | |
Base |
string | |
Bordered |
string | |
FixedLayout |
string | |
Header |
string | |
StickyHeader |
string | |
Body |
string | |
BodyStriped |
string | |
BodyHoverable |
string | |
RowDivider |
string | |
Footer |
string | |
SearchColumn |
string | |
SortIcon |
string | |
HeaderCellPadding |
string | |
BodyCellPadding |
string | |
EmptyState |
string | |
ResizeHandle |
string | |
GroupByColumn |
string | |
GroupRow |
string | |
GroupToggle |
string | |
GroupCount |
string | |
LoadingCell |
string | |
ActionsCell |
string | |
EditingRow |
string | |
FilterPanel |
string | |
FilterHeading |
string |
Full reference: TwTableTheme on the API docs.