DataTable

The console's table: a 36px header on a strong rule, 40px rows on hairlines, numbers right, sorting, resizing, selection, virtualization.

View source
import { DataTable, col } from "@logicplanes/kaeso-ui";

Props

  • activeRowId
    string

    The id of the row whose detail is open, in a sheet beside the table: it keeps the selected fill and is marked aria-current.

  • aria-label
    string

    The table's accessible name.

  • canSelectRow
    ((row: T) => boolean)

    Whether a row can be selected; a row that can't keeps a disabled checkbox, and select all skips it.

  • columns
    ColumnDef<T, any>[]

    The columns, as TanStack Table column definitions.

  • data
    T[]

    The rows.

  • data-force-row
    string

    Force a state on the first row for state matrices: hover, pressed, focus.

  • density
    "default" | "compact" | "comfortable"

    How much room each row gets.

  • empty
    ReactNode

    What to show when there are no rows: an Empty with the page's own sentence, such as "No requests yet" or, behind filters, "No requests match". Without it the table says "No rows".

  • error
    ReactNode

    The rows failed to load: the table says so where its rows would be and offers Try again (onRetry), or, without it, says to reload the page. Errors are toasts, so the value isn't shown; toast the message where the request fails.

  • freshRowIds
    ReadonlySet<string>

    Rows that just arrived (a live list): each shows a fill that fades out over a second.

  • getRowId
    ((row: T) => string)

    Returns a row's stable id, for selection and keys.

  • hasMore
    boolean

    Whether more rows can be loaded.

  • loading
    boolean

    Shows skeleton rows while the first page loads.

  • loadingMore
    boolean

    Shows that more rows are loading.

  • manualSorting
    boolean

    Sorting happens on the server: the data arrives sorted.

  • onHiddenColumnsChange
    ((ids: string[]) => void)

    Called with the ids of the columns left out at the table's width, so a kept column can show what they held.

  • onLoadMore
    (() => void)

    Called to load the next rows. When Load more asked for them, focus moves to the first new row once they arrive; screen readers hear how many came.

  • onRetry
    (() => void)

    Shows a Retry button when loading failed.

  • onRowClick
    ((row: T) => void)

    Called when a row is clicked; rows then show that they can be opened.

  • onSelectionChange
    ((selection: RowSelectionState) => void)

    Called with the selected rows.

  • onSortingChange
    ((sorting: SortingState) => void)

    Called with the new sort order.

  • ref
    Ref<HTMLDivElement>

    A ref to the outer element.

  • rowMenu
    ((row: T) => ReactNode)

    Items for a row's context menu (right-click).

  • selectable
    boolean

    Adds a checkbox to every row, named after the row's first text column; Space, Shift with the arrows and ⌘A select from the keyboard.

  • selection
    RowSelectionState

    The selected rows, when you control them.

  • sorting
    SortingState

    The sort order, when you control it.

  • stickyFirstColumn
    boolean

    Keeps the first column in view while scrolling sideways.

  • virtualizeAbove
    number

    Above this many rows (50), only the visible rows are rendered.