Esc
Documentation
On this page

Props

PropTypeDefaultDescription
sourceDataSourceNoneResource binding to fetch rows from
columnsSourceDataSourceNoneResource binding that supplies the column definitions at run time
datareadonly Record<string, unknown>[]NoneInline data (alternative to source)
columnsreadonly TableColumn[]NoneColumn definitions
variant"default" | "data"NoneVisual style
rowLinkTableRowLinkNoneLink each row to a route
rowActionsreadonly TableRowAction[]NonePer-row action buttons
actionsreadonly TableRowMenuAction[]NoneTable-level menu actions
searchablebooleanNoneShow search input
filtersreadonly TableFilter[]NoneColumn filter dropdowns
pageSizenumberNoneRows per page

Example

ts
Table({
  source: warehouses(),
  columns: [
    { id: "name", label: "Name" },
    { id: "status", label: "Status" },
  ],
  rowActions: [
    {
      label: "Suspend",
      action: suspendWarehouse,
      input: { warehouse: "name" },
      when: { field: "status", equals: "RUNNING" },
    },
  ],
  searchable: true,
})

Supporting types

TableColumn
export interface TableColumn {
  id: string;
  label: string;
  format?: "duration" | "progress" | "eta";
  renderCell?: PageNode | readonly PageNode[];
}
TableRowLink
export interface TableRowLink {
  path: string;
  params: Record<string, string>;
}
TableRowAction
export interface TableRowAction {
  label: string;
  icon?: string;
  variant?: "primary" | "secondary" | "danger";
  action?: AnyActionDefinition | string;
  link?: TableRowLink;
  input?: Record<string, string>;
  successLink?: TableRowLink;
  confirmation?: {
    title: string;
    description: string;
    confirmLabel?: string;
  };
  when?: {
    field: string;
    equals?: string | number | boolean;
    notEquals?: string | number | boolean;
  };
  disabledWhen?: {
    field: string;
    equals?: string | number | boolean;
    notEquals?: string | number | boolean;
  };
}
TableRowMenuAction
export interface TableRowMenuAction {
  label: string;
  action?: AnyActionDefinition | string;
  input?: Record<string, string>;
  link?: TableRowLink;
  successLink?: TableRowLink;
  confirmation?: {
    title: string;
    description: string;
    confirmLabel?: string;
  };
  when?: {
    field: string;
    equals?: string | number | boolean;
    notEquals?: string | number | boolean;
  };
}
TableFilter
export interface TableFilter {
  field: string;
  label: string;
  options: readonly { label: string; value: string }[];
}
PageTableRowLink
export type PageTableRowLink = {
  path: string;
  params: Record<string, string>;
};
PageTableRowAction
export type PageTableRowAction = {
  label: string;
  variant?: "primary" | "secondary" | "danger";
  action: {
    actionId: string;
    input?: Record<string, string>;
  };
  successLink?: PageTableRowLink;
  confirmation?: {
    title: string;
    description: string;
    confirmLabel?: string;
  };
  when?: {
    field: string;
    equals?: string | number | boolean;
    notEquals?: string | number | boolean;
  };
  disabledWhen?: {
    field: string;
    equals?: string | number | boolean;
    notEquals?: string | number | boolean;
  };
};

View the source on GitHub