Skip to main content

Column pinning

Prop enableColumnPinning — engine behaviour, default false.

Guide

When to use it

Keep key columns — an id, a name, an action column — visible while the rest scroll horizontally.

How it works

Adds pin-left / pin-right controls to the columns menu; pinned columns become sticky at the edges of the scroll area. State is { start, end } column-id lists.

Gotchas

  • Surface the control with showColumnsMenu.
  • Column virtualization falls back to rendering all columns while pinning is active (the two don't stack).
  • The row-number column (enableRowNumbers) pins to the start ahead of user pins.

Live example

Example source
import React from 'react'
import { BstTableMui } from '@bloomskill/table-mui'
import type { BstTableColumn } from '@bloomskill/table-engine'
import '@bloomskill/table-engine/styles.css'

type Row = { id: string; name: string; team: string; role: string; score: number }
const seed: Row[] = [
{ id: '1', name: 'Ada Lovelace', team: 'Platform', role: 'Engineer', score: 92 },
{ id: '2', name: 'Alan Turing', team: 'Research', role: 'Scientist', score: 88 },
{ id: '3', name: 'Grace Hopper', team: 'Platform', role: 'Engineer', score: 95 },
{ id: '4', name: 'Katherine J.', team: 'Research', role: 'Analyst', score: 90 },
{ id: '5', name: 'Edsger Dijkstra',team: 'Platform', role: 'Architect',score: 84 },
]
const columns: BstTableColumn<Row>[] = [
{ id: 'name', accessorKey: 'name', header: 'Name' },
{ id: 'team', accessorKey: 'team', header: 'Team' },
{ id: 'role', accessorKey: 'role', header: 'Role' },
{ id: 'score', accessorKey: 'score', header: 'Score', sortFn: 'basic' },
]

export default function App() {
return (
<BstTableMui data={seed} columns={columns} getRowId={(r) => r.id}
enableColumnPinning enableColumnOrdering showColumnsMenu />
)
}
Loading live example…

Live example

Column pinning — the Name column stays frozen while the rest scroll

Example source
import React from 'react'
import { BstTableMui } from '@bloomskill/table-mui'
import type { BstTableColumn } from '@bloomskill/table-engine'
import '@bloomskill/table-engine/styles.css'
type Row = { id: string; name: string; team: string; role: string; score: number }
const seed: Row[] = [
{ id: '1', name: 'Ada Lovelace', team: 'Platform', role: 'Engineer', score: 92 },
{ id: '2', name: 'Alan Turing', team: 'Research', role: 'Scientist', score: 88 },
{ id: '3', name: 'Grace Hopper', team: 'Platform', role: 'Engineer', score: 95 },
{ id: '4', name: 'Katherine J.', team: 'Research', role: 'Analyst', score: 90 },
{ id: '5', name: 'Edsger Dijkstra', team: 'Platform', role: 'Architect', score: 84 },
]
const columns: BstTableColumn<Row>[] = [
{ id: 'name', accessorKey: 'name', header: 'Name' },
{ id: 'team', accessorKey: 'team', header: 'Team' },
{ id: 'role', accessorKey: 'role', header: 'Role' },
{ id: 'score', accessorKey: 'score', header: 'Score', sortFn: 'basic' },
]
const wide: BstTableColumn<Row>[] = [
...columns,
{ id: 'c5', accessorKey: 'role', header: 'Department' },
{ id: 'c6', accessorKey: 'team', header: 'Division' },
{ id: 'c7', accessorKey: 'role', header: 'Title' },
{ id: 'c8', accessorKey: 'team', header: 'Location' },
{ id: 'c9', accessorKey: 'role', header: 'Level' },
]
export default function App() {
return (
<BstTableMui data={seed} columns={wide} getRowId={(r) => r.id}
enableColumnPinning initialState={{ columnPinning: { start: ['name'], end: [] } }} />
)
}
Loading live example…

Overview

Layerenable* (engine, resolved in useBstTable)
Typeboolean
Defaultfalse
Maps tov9 enableColumnPinning (state {start,end})
Status✅ done (Phase 3)
Sincev0.7.0
Settings sheetColumns

Column pinning (sticky left/right). Maps to v9 enableColumnPinning. Default: false.

Enable it

<BstTableMui
data={rows}
columns={columns}
enableColumnPinning
/>

Swap BstTableMui for BstTableShadcn (and the CSS import) for the shadcn skin — same props.