Shadcn React Table

Search documentation

Search the docs

Column visibility

A "Columns" toggle in the toolbar lets users show or hide columns. Each column-actions menu also has a Hide item for the same effect.

Column visibility
GitHub
ID
AvaThompsonOwnerEngineeringactive22$45,000
LiamNguyenAdminMarketinginactive25$47,137
NoahSilvaEditorDesignpending28$49,274
EmmaCarterViewerSalesactive31$51,411
OliviaRossiOwnerSupportinactive34$53,548
WilliamWalkerAdminEngineeringpending37$55,685
SophiaPatelEditorMarketingactive40$57,822
JamesMullerViewerDesigninactive43$59,959
IsabellaParkOwnerSalespending46$62,096
LucasReyesAdminSupportactive49$64,233
$4,120,536
Rows per page
1–10 of 48
const table = useDataTable({
  data,
  columns,
  getRowId: (row) => row.id,
})

return <DataTable table={table} />

Initial hidden columns

Hide columns from the start with initialState.columnVisibility, mapping a column id to false.

const table = useDataTable({
  data,
  columns,
  initialState: {
    columnVisibility: { startDate: false },
  },
})

Prevent hiding a column

Use TanStack's enableHiding: false on a column definition to keep it always visible. It will not appear in the toggle or expose a Hide item.

const columns = [
  { accessorKey: "firstName", enableHiding: false },
]

Always-on columns

Columns with enableHiding: false stay rendered regardless of toolbar or menu actions.