Skip to main content

DataTable

Production-ready data table with automatic data fetching and state management

Example

"use client";

import { DataTable } from "@databricks/appkit-ui/react";

export default function DataTableExample() {
  return (
    <DataTable
      queryKey="example_query"
      parameters={{}}
      filterColumn="name"
      filterPlaceholder="Filter by name..."
      pageSize={10}
    />
  );
}

DataTable

Production-ready data table with automatic data fetching and state management

Features:

  • Automatic column generation from data structure
  • Integrated with useAnalyticsQuery for data fetching
  • Built-in loading, error, and empty states
  • Dynamic filtering, sorting and pagination
  • Column visibility controls
  • Responsive design
  • Supports opinionated mode (auto columns) and full-control mode (children(table))

In opinionated mode the columns are the keys of the first row that match /^[a-zA-Z_][a-zA-Z0-9_]*$/ (other keys are dropped), headed by the key in Title Case. Every cell whose value parses as a number, numeric strings included, is right-aligned and formatted: a key containing cost, price, spend, revenue or usd shows as USD, and any other value of 1000 or more is abbreviated (10021 shows as 10K). For ids, zip codes or years, render a Table from useAnalyticsQuery rows instead.

Source: packages/appkit-ui/src/react/table/data-table.tsx

Props

PropTypeRequiredDefaultDescription
queryKeystring✓-The query key to fetch the data
parametersRecord<string, any>✓-The parameters to pass to the query
filterColumnstring-The column to filter by
filterPlaceholderstring-Optional placeholder for the filter input
transform((data: any[]) => any[])-Optional function to transform data before creating table. A new function reference re-runs it and resets the table to the first page, so define it outside the component or wrap it in useCallback.
labelsDataTableLabels-Optional labels for the DataTable component
ariaLabelstring-Optional accessibility label for the DataTable component
testIdstring-Optional test ID for the DataTable component
classNamestring-Optional CSS class name for the DataTable component
enableRowSelectionboolean-Enable row selection with checkboxes
onRowSelectionChange((rowSelection: RowSelectionState) => void)-Callback function to handle row selection changes
children((table: Table<any>) => ReactNode)-Optional children for full control mode
pageSizenumber-Number of rows to display per page
pageSizeOptionsnumber[]-Options for the page size selector

Usage

import { DataTable } from '@databricks/appkit-ui';

<DataTable /* props */ />

Databricks Developer Hub

Ready to ship your next agentic app in minutes?

Read docs