DocsAPI Reference

API Reference

Cell Instance APIs

All the cell instance methods and objects that can be accessed from a cell in Shadcn Table


Every cell provides a cell object that can be used in many props or column definitions that let's you have access to a cell's information and methods.

You can access and use a cell object in quite a few places, but here are some of the most common:

const columns = [
  {
    accessorKey: 'username',
    header: 'Username',
    //you can access a cell in many callback column definition options like this
    stTableBodyCellProps: ({ cell }) => ({
      onClick: () => {
        console.log(cell.getValue(), cell.id);
      },
    }),
    //or in the component override callbacks like this
    Cell: ({ cell }) => {
      return <div>{cell.getValue()}</div>;
    },
  },
];

const table = useShadcnTable({
  columns,
  data,
  //or in callback props like this
  stEditTextFieldProps: ({ cell }) => ({
    disabled: cell.getValue() === 'admin',
  }),
});

NOTE: These are NOT props or column options for Shadcn Table. These are just static methods on a cell instance that you can use.

State OptionTypeDescription
columnST_Column<TData>The associated Column object for the cell.
getContext() => { table: Table<TData>; column: ST_Column<TData, TValue>; row: ST_Row<TData>; cell: Cell<TData, TValue>; getValue: <TTValue = TValue>() => TTValue; renderValue: <TTValue = TValue>() => TTValue | null; }Returns the rendering context (or props) for cell-based components like cells and aggregated cells.
getIsAggregatedNot ProvidedNot Provided
getIsGroupedNot ProvidedNot Provided
getIsPlaceholderNot ProvidedNot Provided
getValue() => anyReturns the value for the cell, accessed via the associated column's accessor key or accessor function.
idstringThe unique ID for the cell across the entire table.
renderValueNot ProvidedWorks similar to getValue(), but has been deprecated in favor of the `flexRender` import.
rowST_Row<TData>The associated Row object for the cell.

Wanna see the source code for this table? Check it out down below!