Table
A feature-rich data table with sorting, filtering, row selection, column reordering/visibility, and context menus. All table operations (sorting, filtering, reordering) are handled C++-side by Dear ImGui — the JS event callbacks are informational.
Basic usage
import { useRef, useEffect } from "react";
import { TableImperativeHandle } from "@xframes/common";
const columns = [
{ heading: "Name", fieldId: "name" },
{ heading: "Age", fieldId: "age", type: "number" as const },
];
const App = () => {
const tableRef = useRef<TableImperativeHandle>(null);
useEffect(() => {
tableRef.current?.setTableData([
{ name: "Alice", age: 30 },
{ name: "Bob", age: 25 },
]);
}, []);
return (
<XFrames.Node root style={{ height: "100%" }}>
<XFrames.Table
ref={tableRef}
columns={columns}
style={{ width: "100%", flex: 1 }}
/>
</XFrames.Node>
);
};
Props
| Prop | Type | Description |
|---|---|---|
columns | ColumnConfig[] | Required. Column definitions |
clipRows | number | Number of visible rows before scrolling |
filterable | boolean | Show per-column filter inputs |
reorderable | boolean | Allow column drag-to-reorder |
hideable | boolean | Allow column visibility toggles |
contextMenuItems | { id: string; label: string }[] | Right-click menu options for rows |
onSort | (event: TableSortEvent) => void | Fires when a column is sorted |
onFilter | (event: TableFilterEvent) => void | Fires when a column filter changes |
onRowClick | (event: TableRowClickEvent) => void | Fires when a row is clicked |
onItemAction | (event: TableItemActionEvent) => void | Fires when a context menu item is clicked |
All four style variants are supported (style, hoverStyle, activeStyle, disabledStyle).
Column configuration
Each entry in the columns array configures one column:
| Field | Type | Default | Description |
|---|---|---|---|
heading | string |