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, right, or unpin it.
Use pinned to set the initial pinning state for pinnable columns. The pinning state is persisted in localStorage when you provide a storeColumnsKey prop to the DataTable. You can also use the resetColumnsPinning function from the useDataTableColumns hook to reset pinning to default values.
Direction:
Here is the code:
Combining pinning with column toggling
You can combine pinnable with toggleable on the same columns. This allows users to both pin/unpin columns and show/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:














