ExamplesColumns & Pinning
Pinning
Pin columns left or right, resize edges, double-click autosize, hide and restore.
The column surface in one grid: Name is pinned left and Score pinned right by default, Email
opts out of resizing, and the long Bio column is a flex: 1 autosize target. Pinning, resize,
reorder, and visibility are all on by default and adjustable per column (pinnable,
resizable, reorderable) or grid-wide (enableColumnPinning, etc.). To pin rows too, see the
rows pinning example.
Drag a header's edge to resize (Email is fixed), double-click an edge to autosize the long Bio column, or drag a header to reorder. Hover a header for its menu (or right-click) to pin, hide, or autosize — the toolbar's columns menu restores anything hidden.
pnpm dlx shadcn@latest add @gridcn/data-grid-pinning-demo
What's in the demo
pin: "left"/pin: "right": pinned bands with the frozen-edge shadowresizable: falseon Email. Drag another header's edge to resizeflex: 1on Bio: double-click a header edge to autosize to its content- Header dropdown (hover a header for the ghost chevron, or right-click): pin/unpin, autosize
- Toolbar columns menu: hide a column, then restore it the same way
Behavior reference
- Pin left/right: pin semantics and the persistent indicator
- Resize: drag, double-click autosize, per-column opt-out
- Visibility: hide/restore and what happens to pinned state
- Flex fill: how
flexdistributes the leftover width
Related
- Drag & drop: moving columns (drag or programmatic)
- Column layout: persisting all of the above