Skip to main content

Context menu

Prop enableContextMenu — engine behaviour, default false.

Guide

When to use it

Give users a right-click menu on cells — the fast path to copy, export and autosize where their cursor already is.

How it works

A dependency-free popup at the cursor. Default items adapt to what's on: Copy / Copy row / Copy column (with clipboard), Export CSV / Excel (with export), Autosize column. Reshape it entirely with getContextMenuItems(ctx) (spread ctx.defaultItems to extend).

enableContextMenu
getContextMenuItems={(ctx) => [...ctx.defaultItems, { label: 'Flag row', onSelect: () => flag(ctx.row) }]}

Gotchas

  • Right-clicking first selects the target cell.
  • Default copy / export items only appear when their features (enableClipboard / enableExport) are on.

Live example

Context menu — right-click a cell for Copy / Export / Autosize

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}
enableCellSelection enableClipboard enableContextMenu enableExport />
)
}
Loading live example…

Overview

Layerenable* (engine, resolved in useBstTable)
Typeboolean
Defaultfalse
Maps tocustom — dep-free right-click popup at the cursor (event-delegated on the scroll box via data-bst-rowid/-colid). Default items: Copy / Copy row / Copy column (with clipboard), Export CSV / Excel (with export), Autosize column; reshape via getContextMenuItems(ctx) → BstContextMenuItem[] (spread ctx.defaultItems). Right-click selects the cell. In settings ("Selection & clipboard", always shown). Both skins inherit it
Status✅ done
Sincev0.36.0
Settings sheetSelection & clipboard

Right-click context menu — a menu at the cursor with default actions (Copy · Copy row · Copy column while clipboard is on; Export CSV / Excel while export is on; Autosize column) plus any items returned by getContextMenuItems. If the resolved item list is empty the native browser menu is left alone. Default: false.

Enable it

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

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

Options

OptionNotes
getContextMenuItemsRelated prop for this feature.

Behavior & interactions

  • Right-click a cell for a menu. Default items: Copy / Copy row / Copy column (with enableClipboard), Export CSV / Excel (with enableExport), Autosize column. Reshape or extend them via the getContextMenuItems(ctx) callback (spread ctx.defaultItems).