MiHCM
data/@mihcm/ui·v0.21.0·stable

DataTable

Full-featured data table powered by TanStack Table v8. Sorting, filtering, pagination, selection, column visibility, expandable rows, column resize, column/row pinning, grouping, and faceted filtering — all via boolean props. 5 visual variants.

Sortable table

Click any column header to cycle through ascending, descending, and unsorted states.

Aisha KumariEngineering
Malik ChenDesign
Sara JohanssonProduct
James RiveraEngineering
Priya PatelDesign
Liam OkonkwoEngineering
Yuki TanakaProduct
Elena VasquezEngineering
import { DataTable, DataTableColumnHeader } from '@mihcm/ui/DataTable';
 
const columns = [
  {
    accessorKey: 'name',
    header: ({ column }) => <DataTableColumnHeader column={column} title="Name" />,
  },
  {
    accessorKey: 'department',
    header: ({ column }) => <DataTableColumnHeader column={column} title="Department" />,
  },
];
 
<DataTable columns={columns} data={employees} sortable />

Multi-sort

Hold Shift and click additional column headers to sort by multiple columns simultaneously.

Aisha KumariEngineering
Malik ChenDesign
Sara JohanssonProduct
James RiveraEngineering
Priya PatelDesign
Liam OkonkwoEngineering
Yuki TanakaProduct
Elena VasquezEngineering
<DataTable columns={columns} data={employees} sortable multiSort />

Searchable with pagination

Aisha KumariEngineering
Malik ChenDesign
Sara JohanssonProduct
James RiveraEngineering
Priya PatelDesign
Rows per page
Page 1 of 2
<DataTable
  columns={columns}
  data={employees}
  searchable
  searchPlaceholder="Search employees..."
  paginated
  pageSize={5}
  pageSizeOptions={[5, 10, 20]}
/>

Row selection with callback

Aisha KumariEngineering
Malik ChenDesign
Sara JohanssonProduct
James RiveraEngineering
Priya PatelDesign
Liam OkonkwoEngineering
Yuki TanakaProduct
Elena VasquezEngineering
const [selection, setSelection] = useState({});
 
<DataTable
  columns={columns}
  data={employees}
  selectable
  onRowSelectionChange={setSelection}
/>

Expandable rows

Aisha KumariEngineering
Malik ChenDesign
Sara JohanssonProduct
James RiveraEngineering
Priya PatelDesign
Liam OkonkwoEngineering
Yuki TanakaProduct
Elena VasquezEngineering
<DataTable
  columns={columns}
  data={employees}
  expandable
  renderSubComponent={({ row }) => (
    <div className="p-4">
      <p>Email: {row.original.email}</p>
      <p>Salary: ${row.original.salary.toLocaleString()}</p>
    </div>
  )}
/>

Per-column filters

Enable columnFilterable for individual filter inputs in a dedicated filter row below the column headers. Text columns get a search input; number columns get a range filter when combined with faceted.

Aisha KumariEngineering
Malik ChenDesign
Sara JohanssonProduct
James RiveraEngineering
Priya PatelDesign
Liam OkonkwoEngineering
Yuki TanakaProduct
Elena VasquezEngineering
<DataTable
  columns={columns}
  data={employees}
  columnFilterable
/>

Faceted filtering

Combines columnFilterable with faceted to show unique-value dropdowns for text columns and min/max range inputs for number columns.

Aisha KumariEngineering
Malik ChenDesign
Sara JohanssonProduct
James RiveraEngineering
Priya PatelDesign
Liam OkonkwoEngineering
Yuki TanakaProduct
Elena VasquezEngineering
<DataTable
  columns={columns}
  data={employees}
  columnFilterable
  faceted
/>

Column resizing

Drag column borders to resize. Column widths persist during the session.

Aisha KumariEngineering
Malik ChenDesign
Sara JohanssonProduct
James RiveraEngineering
Priya PatelDesign
Liam OkonkwoEngineering
Yuki TanakaProduct
Elena VasquezEngineering
<DataTable columns={columns} data={employees} resizable />

Row grouping

Group rows by a column value. Grouped rows show an expand/collapse toggle with the group label and row count.

Aisha KumariEngineering
Malik ChenDesign
Sara JohanssonProduct
James RiveraEngineering
Priya PatelDesign
Liam OkonkwoEngineering
Yuki TanakaProduct
Elena VasquezEngineering
<DataTable columns={columns} data={employees} groupable />

Styled variants

DataTable inherits all 5 visual variants from the Table primitive.

Aisha KumariEngineering
Malik ChenDesign
Sara JohanssonProduct
Aisha KumariEngineering
Malik ChenDesign
Sara JohanssonProduct
Aisha KumariEngineering
Malik ChenDesign
Sara JohanssonProduct
Aisha KumariEngineering
Malik ChenDesign
Sara JohanssonProduct
<DataTable columns={columns} data={employees} variant="bordered" />
<DataTable columns={columns} data={employees} variant="striped" />
<DataTable columns={columns} data={employees} variant="minimal" />
<DataTable columns={columns} data={employees} variant="card" />

All features enabled at once. Use wide with dense toolbars, selection, column filters, and resizing so the table keeps readable columns and scrolls horizontally when needed.

Aisha KumariEngineeringaisha@example.com$95,000
Malik ChenDesignmalik@example.com$88,000
Sara JohanssonProductsara@example.com$92,000
James RiveraEngineeringjames@example.com$105,000
Priya PatelDesignpriya@example.com$91,000
0 of 8 row(s) selected
Rows per page
Page 1 of 2
<DataTable
  columns={columns}
  data={employees}
  searchable
  sortable
  multiSort
  paginated
  pageSize={5}
  selectable
  columnVisibility
  columnFilterable
  faceted
  resizable
  wide
  expandable
  variant="card"
  renderSubComponent={({ row }) => (
    <div className="p-4 bg-muted/30">
      {/* Employee detail card */}
    </div>
  )}
/>