Examples › Pinning arbitrary columns
pin, pinned, fix, fixed, affix, sticky, arbitrary, multiple, columnsIn addition to pinning the first column and pinning the last column using the pinFirstColumn and pinLastColumn DataTable props, you can pin arbitrary columns to the left or right side of the table by setting the pinned property on individual column definitions.
Pinning multiple columns to the left
Set pinned: 'left' on any columns you want pinned to the left side of the table:
Here is the code:
Pinning columns to both sides
You can combine left-pinned and right-pinned columns. In this example, the first two columns are pinned to the left, and the actions column is pinned to the right. This also works with row selection:
Here is the code:
Interactive pinning
You can allow users to pin and unpin columns interactively by setting pinnable: true on columns. When enabled, a pin icon appears in the column header on hover. Clicking it reveals a dropdown where users can choose to pin the column to the left or to the right, or to unpin it.
For pinnable columns, pinned sets the initial pinning state. Interactive pinning relies on the same mechanism as column dragging and toggling: provide a storeColumnsKey prop to the DataTable — it’s required for interactive pinning, since the pinning state is kept in local storage under this key. If you also need to restore the initial pinning state, call the useDataTableColumns() hook with the same key and use the resetColumnsPinning() function it returns.
Pinning also works in right-to-left layouts, where the “left” and “right” sides are mirrored. Use the direction switch in the example below to see it in action:
Direction:
Here is the code:
Combining pinning with column toggling
You can combine pinnable with toggleable on the same columns, allowing users to both pin or unpin columns and show or hide them. Right-click on the table header to open the column visibility menu.
In this example, some columns are hidden by default using defaultToggle: false. Use the resetColumnsToggle and resetColumnsPinning functions to reset visibility and pinning independently.
Here is the code:
Pinning with column groups
When using column groups with interactive pinning, you can pin individual columns within groups. The group header will be pinned only when all columns in the group are pinned to the same side. If columns within a group have different pinning states (some pinned left, some unpinned, or mixed), the group header will not be pinned.
Try pinning and unpinning columns in the example below to see how the group headers behave:
Here is the code:
Head over to the next example to discover more features.














