pub fn DataTable(props: DataTableProps) -> impl IntoViewExpand description
Presents sortable, filterable tabular data with built-in toolbar, selection, and pagination.
Bind columns and items (or data_source) to get a working table. Enable advanced capabilities
via DataTableFeatures and tune toolbar/header chrome with DataTableToolbarConfig and
DataTableHeaderChromeConfig. For static HTML tables without a data engine, use
Table instead.
§When to use
- Interactive grids over medium client-side datasets with sort, search, and pagination
- Server-driven paging, sort, and filter via
DataTableSource::Server - Admin views that need selection, editing, export, or grouping
§When to use Table instead
Use Table for static or lightly interactive content
without a built-in data engine.
§Usage
- Define columns with
DataTableColumnDef— see Column Definition. - Supply rows via
itemsordata_source. - Enable feature flags on
featuresas needed (pinning, virtualization, pivot, etc.). - Customize toolbar and header chrome with
toolbar_configandheader_chromewithout replacing slots.
§Best Practices
§Do’s
- Bind columns to
FieldDefkeys viaDataTableColumnDef::field - Wrap rows as
DataTableRowModelover typedDataRecordvalues - Prefer
data_sourcefor explicit client/server mode;itemsis sugar for client signals - Use topic pages under Data Table for column, row, editing, and state patterns
§Don’ts
- Do not replace the entire toolbar when you only need to hide one control — use
toolbar_config - Do not use raw HTML for toolbar/footer controls — the built-in chrome uses Orbital primitives
§DataTable topic guide
- Columns — Column Definition, Column Features
- Rows — Rows
- Editing — Editing
- Sort & filter — Sorting & Filtering
- Data & paging — Data Source & Pagination
- Selection & export — Selection, Export & Clipboard
- UX — Rendering & UX
- Advanced — Tree, Grouping & Pivot, Charts Integration
- State — State & Handle
§Toolbar and header chrome
| Field | Type | Default | Description |
|---|---|---|---|
quick_search | bool | true | Quick-search field in the toolbar |
filter_panel | bool | true | Structured filter panel trigger |
column_picker | bool | true | Column visibility picker trigger |
pivot | bool | true | Pivot panel trigger (requires PIVOTING) |
export_menu | bool | true | Export/print menu trigger |
DataTableHeaderChromeConfig gates per-header menu, filter button, and hide-column UX.
See Column Features for header chrome interaction with column menus.
§Examples
§Default data table
Sortable columns with quick search and pagination.
use crate::{DataTable, DataTableColumnDef, DataTableRowModel};
use std::collections::HashMap;
let items = RwSignal::new(vec![
DataTableRowModel::from_text_cells("1", HashMap::from([("name".into(), "Ada".into()), ("role".into(), "Admin".into())])),
DataTableRowModel::from_text_cells("2", HashMap::from([("name".into(), "Grace".into()), ("role".into(), "Editor".into())])),
]);
view! {
<div data-testid="data-table-preview">
<DataTable
sortable=true
columns=vec![
DataTableColumnDef::new("name", "Name"),
DataTableColumnDef::new("role", "Role"),
]
items=items
/>
</div>
}§Row selection
Multiselect with checkboxes.
use crate::{DataTable, DataTableColumnDef, DataTableRowModel, DataTableSelectionMode};
use std::collections::HashMap;
let items = RwSignal::new(vec![
DataTableRowModel::from_text_cells("a", HashMap::from([("name".into(), "Alpha".into())])),
DataTableRowModel::from_text_cells("b", HashMap::from([("name".into(), "Beta".into())])),
]);
view! {
<div data-testid="data-table-selection">
<DataTable
selection_mode=DataTableSelectionMode::Multiselect
columns=vec![DataTableColumnDef::new("name", "Name")]
items=items
/>
</div>
}§Density variants
Row and header heights respond to theme density.
use crate::{DataTable, DataTableColumnDef, DataTableRowModel};
use orbital_core_components::{Flex, FlexGap, ThemeDensityStepper};
use std::collections::HashMap;
let items = RwSignal::new(vec![
DataTableRowModel::from_text_cells("1", HashMap::from([("name".into(), "Ada".into())])),
]);
view! {
<div data-testid="data-table-density">
<Flex vertical=true gap=FlexGap::Medium>
<ThemeDensityStepper />
<DataTable
columns=vec![DataTableColumnDef::new("name", "Name")]
items=items
/>
</Flex>
</div>
}§Layout
Fixed height and flex-fill in a bounded parent.
use std::collections::HashMap;
use crate::{DataTable, DataTableColumnDef, DataTableRowModel, PagingMode};
let items = RwSignal::new((0..30).map(|i| {
DataTableRowModel::from_text_cells(&i.to_string(), HashMap::from([("name".into(), format!("Row {i}"))]))
}).collect::<Vec<_>>());
view! {
<div data-testid="data-table-layout-preview" style="display: flex; flex-direction: column; height: 350px;">
<DataTable
flex=true
max_height=280.0
paging=PagingMode::None
columns=vec![DataTableColumnDef::new("name", "Name")]
items=items
/>
</div>
}§Custom slots
Replace toolbar, footer, and empty views with custom content via Leptos slot children.
use std::collections::HashMap;
use crate::{
DataTable, DataTableColumnDef, DataTableEmptyView, DataTableFooterSlot,
DataTableRowModel, DataTableToolbarSlot, PagingMode,
};
use orbital_core_components::{Toolbar, ToolbarButton};
let empty: RwSignal<Vec<DataTableRowModel>> = RwSignal::new(vec![]);
view! {
<div data-testid="data-table-slots-preview">
<DataTable
paging=PagingMode::None
max_height=200.0
columns=vec![DataTableColumnDef::new("name", "Name")]
items=empty
>
<DataTableToolbarSlot slot>
<div data-testid="custom-toolbar">
<Toolbar><ToolbarButton>"Custom toolbar"</ToolbarButton></Toolbar>
</div>
</DataTableToolbarSlot>
<DataTableFooterSlot slot>
<div data-testid="custom-footer">"Custom footer"</div>
</DataTableFooterSlot>
<DataTableEmptyView slot>
<div data-testid="custom-empty">"No data yet"</div>
</DataTableEmptyView>
</DataTable>
</div>
}§Toolbar and header chrome
Toggle built-in toolbar controls and column-header actions without replacing the whole toolbar.
use std::collections::HashMap;
use crate::{
DataTable, DataTableColumnDef, DataTableHeaderChromeConfig, DataTableRowModel,
DataTableToolbarConfig, PagingMode,
};
let items = RwSignal::new(vec![
DataTableRowModel::from_text_cells("1", HashMap::from([("name".into(), "Ada".into())])),
]);
view! {
<div data-testid="data-table-chrome-config-preview">
<DataTable
paging=PagingMode::None
max_height=200.0
toolbar_config=DataTableToolbarConfig {
quick_search: true,
filter_panel: false,
column_picker: false,
pivot: false,
export_menu: true,
}
header_chrome=DataTableHeaderChromeConfig {
column_menu: false,
column_filter_button: false,
column_hide: false,
}
columns=vec![DataTableColumnDef::new("name", "Name")]
items=items
/>
</div>
}§Optional Props
- class:
impl Into<MaybeProp<String>>- Extra CSS class names merged onto the root element.
- columns:
Vec<DataTableColumnDef>- Column definitions (bind to dataset schema field keys).
- data_source:
DataTableSource- Unified data source (client signal or server fetcher).
- paging:
PagingMode- Pagination presentation (
Paged,InfiniteScroll, orNone).
- Pagination presentation (
- items:
RwSignal<Vec<DataTableRowModel>>- Reactive row data (sugar for
DataTableSource::Clientwhendata_sourceis omitted).
- Reactive row data (sugar for
- edit_mode:
EditMode- Inline edit scope: single cell or whole row.
- show_undo_toolbar:
bool- Show undo/redo toolbar (typically enabled in undo preview).
- features:
DataTableFeatures- Opt-in capability flags.
- toolbar_config:
DataTableToolbarConfig- Built-in toolbar control visibility (ignored when a custom toolbar slot is provided).
- header_chrome:
DataTableHeaderChromeConfig- Column header chrome visibility (menu, filter button, hide-column UX).
- sortable:
bool- Enable column header sorting.
- resizable_columns:
bool- Enable drag resize on column headers.
- column_groups:
Vec<DataTableColumnGroupDef>- Optional nested column groups for multi-row headers.
- header_height:
f64- Optional override for header row height in pixels.
- height:
f64- Fixed height for the scroll body in pixels (enables vertical scroll).
- max_height:
f64- Optional max height for the scroll body (enables vertical scroll).
- flex:
bool- Fill available height in a flex parent (
flex: 1; min-height: 0).
- Fill available height in a flex parent (
- auto_row_height:
bool- Allow rows to grow taller than the density-mapped minimum height.
- locale:
DataTableLocale- Localized UI strings (footer, overlays, search placeholder).
- pagination_display:
PaginationDisplayFormat- Footer pagination label format (
Localerange vs legacyPlaincount).
- Footer pagination label format (
- page_size_options:
Option<Vec<u32>>- Rows-per-page options for footer Select (
Nonehides the selector).
- Rows-per-page options for footer Select (
- data_table_toolbar:
DataTableToolbarSlot- Custom toolbar — nest with
<DataTableToolbarSlot slot>.
- Custom toolbar — nest with
- data_table_toolbar_slot:
DataTableToolbarSlot- Deprecated — use [
data_table_toolbar].
- Deprecated — use [
- data_table_footer:
DataTableFooterSlot- Custom footer — nest with
<DataTableFooterSlot slot>.
- Custom footer — nest with
- data_table_footer_slot:
DataTableFooterSlot- Deprecated — use [
data_table_footer].
- Deprecated — use [
- data_table_empty_view:
DataTableEmptyView- Custom empty-state overlay — nest with
<DataTableEmptyView slot>.
- Custom empty-state overlay — nest with
- data_table_no_results_view:
DataTableNoResultsView- Custom no-results overlay — nest with
<DataTableNoResultsView slot>.
- Custom no-results overlay — nest with
- data_table_loading_view:
DataTableLoadingView- Custom loading overlay — nest with
<DataTableLoadingView slot>.
- Custom loading overlay — nest with
- loading:
RwSignal<bool>- Client-controlled loading state for overlay display.
- dir:
Direction- Text direction override (defaults to theme direction).
- get_row_class:
Callback<(DataTableRowModel, usize), String>- Per-row CSS class callback.
- get_row_id:
GetRowId- Custom row id resolver (default: [
DataRecord::id]).
- Custom row id resolver (default: [
- get_tree_path:
GetTreePath- Hierarchical path resolver for tree data (
TREE_DATA).
- Hierarchical path resolver for tree data (
- row_grouping:
DataTableRowGrouping- Row grouping model (
ROW_GROUPING).
- Row grouping model (
- aggregation:
AggregationModel- Aggregation rules for footer/group summaries (
AGGREGATION).
- Aggregation rules for footer/group summaries (
- aggregation_position:
AggregationPosition- Where aggregate values render (footer or inline on groups).
- pivot:
DataTablePivotModel- Pivot configuration (
PIVOTING).
- Pivot configuration (
- list_view:
ListViewConfig- List view card layout config (
LIST_VIEW).
- List view card layout config (
- data_table_row_detail:
DataTableRowDetail- Custom row detail panel — nest with
<DataTableRowDetail slot render=... />.
- Custom row detail panel — nest with
- row_detail:
RowDetailView- Deprecated — use
DataTableRowDetailslot or [data_table_row_detail].
- Deprecated — use
- selection_mode:
DataTableSelectionMode- Row selection mode (
SingleorMultiselect).
- Row selection mode (
- initial_state:
DataTableInitialState- One-time initial state (sort, search, pagination, selection).
- sort:
Signal<Option<DataTableSort>>- Controlled sort model (
None= uncontrolled).
- Controlled sort model (
- filter:
Signal<Option<DataTableFilter>>- Controlled filter model (
None= uncontrolled).
- Controlled filter model (
- pagination:
Signal<Option<PaginationState>>- Controlled pagination (
None= uncontrolled).
- Controlled pagination (
- selection:
Signal<Option<std::collections::HashSet<String>>>- Controlled selection ids (
None= uncontrolled).
- Controlled selection ids (
- server_fetch_policy:
ServerFetchPolicy- Server fetch invalidation: drop stale in-flight responses; optional
ServerFetchPolicy::dedupe_key.
- Server fetch invalidation: drop stale in-flight responses; optional
- data_table_events:
DataTableEvents- Side-effect callbacks for table integration.
- events:
DataTableEvents- Deprecated — prefer [
data_table_events].
- Deprecated — prefer [
- on_handle:
Callback<DataTableHandle, ()>- Deprecated — prefer
data_table_events.on_handle.
- Deprecated — prefer
- children:
Children- Additional children (provider context, etc.).