Click column headers to sort. Pagination buttons load new pages via htmx.
<!-- The table is in a partial view: _DataTablePartial.cshtml -->
<div id="htmx-table-container">
@await Html.PartialAsync("_DataTablePartial", state)
</div>
<!-- Partial re-renders the full table on each request -->
<!-- Sort buttons and pagination target #htmx-table-container -->
<!-- Server handler uses DataTableRequest model binder: -->
public IActionResult OnGetTableData(DataTableRequest request)
{
// sort, filter, paginate...
return Partial("_DataTablePartial", state);
}
Properties
Property
Type
Default
Description
rhx-striped
bool
false
Alternating row backgrounds
rhx-hoverable
bool
false
Row hover highlight
rhx-bordered
bool
false
Cell borders
rhx-compact
bool
false
Reduced padding
rhx-sticky-header
bool
false
Sticky header on scroll
rhx-loading
bool
false
Show loading overlay
rhx-empty-message
string
"No data"
Message when table body is empty
rhx-sort-url
string
-
Base URL for sort/filter htmx requests
rhx-caption
string
-
Accessible caption text
rhx-label
string
-
aria-label for the table
Column Properties
Properties for <rhx-column> elements.
Properties
Property
Type
Default
Description
rhx-field
string
-
Property name for sort/filter query params
rhx-header
string
-
Display header text
rhx-sortable
bool
false
Enable sorting on this column
rhx-sort-direction
string?
null
Current sort: asc, desc, or null
rhx-filterable
bool
false
Enable filter input in header
rhx-filter-value
string?
null
Current filter value
rhx-width
string?
null
CSS width (e.g., 200px, 30%)
rhx-align
string
start
Text alignment: start, center, end
Pagination Properties
Properties for <rhx-data-table-pagination> elements.
Properties
Property
Type
Default
Description
rhx-page
int
1
Current page number (1-based)
rhx-page-size
int
10
Rows per page
rhx-total-items
int
0
Total row count
rhx-url
string
-
Base URL for page requests
rhx-target
string?
-
htmx target for page requests
Accessibility
The table uses role="grid" with aria-label for assistive technology recognition.
Sort buttons render as native <button> elements with aria-sort reflecting the current state.
Filter inputs have aria-label describing which column they filter.
Pagination buttons have aria-label for each action (first, previous, next, last page).
Loading state sets aria-busy="true" on the container.
The <caption> element provides an accessible description of the table's purpose.