gridcn1.2.2

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.

Name
Email
Role
Joined
Age
Bio (double-click edge to autosize)
Score
Silent Tiger
user0@example.com
Viewer
2023-07-05
63
Silent Tiger has been a viewer since 2023-07-05.
4
Quick Lion
user1@example.com
Viewer
2021-04-03
67
Quick Lion has been a viewer since 2021-04-03.
89
Swift Wolf
user2@example.com
Manager
2020-10-27
40
Swift Wolf has been a manager since 2020-10-27.
80
Eager Lion
user3@example.com
User
2022-10-08
50
Eager Lion has been a user since 2022-10-08.
51
Eager Tiger
user4@example.com
Viewer
2024-10-07
45
Eager Tiger has been a viewer since 2024-10-07.
83
Silent Wolf
user5@example.com
User
2020-06-01
24
Silent Wolf has been a user since 2020-06-01.
15
Swift Lion
user6@example.com
Viewer
2022-10-18
34
Swift Lion has been a viewer since 2022-10-18.
62
Eager Lion
user7@example.com
Manager
2021-10-07
21
Eager Lion has been a manager since 2021-10-07.
42
Eager Eagle
user8@example.com
Editor
2024-06-11
25
Eager Eagle has been a editor since 2024-06-11.
35
Bold Tiger
user9@example.com
Editor
2024-03-20
19
Bold Tiger has been a editor since 2024-03-20.
52
Bold Bear
user10@example.com
User
2020-04-16
42
Bold Bear has been a user since 2020-04-16.
28
Swift Wolf
user11@example.com
Manager
2022-08-04
47
Swift Wolf has been a manager since 2022-08-04.
9
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 shadow
  • resizable: false on Email. Drag another header's edge to resize
  • flex: 1 on 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 flex distributes the leftover width

On this page