DataGridColumnVisibility
Dropdown of checkbox items that show/hide the hideable columns of a TanStack
Table.
Only lists columns with an accessor that report getCanHide(), labelling
each from columnDef.meta.headerTitle (falling back to the column id).
Toggling a column keeps the menu open so several can be flipped at once.
Usage
import { DataGridColumnVisibility } from "@desk/ui/components/data-grid-column-visibility";Best practices
Pass the TanStack
tableinstance directly (this part does NOT read DataGrid context) plus atriggerelement rendered viaasChild— supply your ownButton, it renders none.Only accessor columns reporting
getCanHide()appear; setenableHiding: falseon a column def to keep it always-visible and out of this menu.Label each column via
columnDef.meta.headerTitle— the menu falls back to the raw columnidwhen it's missing.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| table | Table<TData> | The TanStack table instance whose column visibility is controlled. | |
| trigger | ReactNode | Element that opens the menu (rendered via |
Composition
Builds on