AsterUIDocsv1.0.2

Docs / Component reference

DataTable

Sort a column or narrow the records with a query. At small widths the table gives each cell its own label.

Data table example

Filter the rows, then sort a column. Open Code + CSS to see the input handler this site added to the registry component.

Install

sh
npx @fierst/ui@1.0.2 add data-table

Registry dependencies: theme, input, icon. Package dependencies: @lucide/icons.

Exports from ./ui/data-table: ColumnDef, DataTable.

Download the registry source for data-table 1.0.2.

API contracts

ts
export interface ColumnDef<T> {
  key: string;
  header: string;
  sortable?: boolean;
  render?: (row: T) => View;
}

export function* DataTable<T extends Record<string, any>>(
  props: {
    rows: readonly T[];
    columns: readonly ColumnDef<T>[];
    rowKey: (row: T) => string | number;
    searchable?: boolean;
    searchPlaceholder?: string;
    emptyText?: string;
    class?: string;
  },
  ctx: Ctx,
)