Skip to main content

Density toggle

Prop showDensityToggle — adapter chrome, default false.

Guide

When to use it

Let users trade whitespace for rows-on-screen — cycle compact / standard / comfortable row heights.

How it works

A toolbar control that cycles a data-bst-density attribute the CSS reads; no data change.

Gotchas

  • It's chrome — lives under showToolbar (in the "⋯ More" menu).
  • Independent of enableRowResize / enableAutoRowHeight (those are per-row; this is the whole grid).

Live example

Density toggle — compact / normal / comfortable row heights

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}
showDensityToggle />
)
}
Loading live example…

Overview

Layershow* (chrome, resolved in the adapter)
Typeboolean
Defaultfalse
Maps toadapter toolbar (data-bst-density)
Status✅ done (Phase 3)
Sincev0.7.0
Settings sheetDisplay

Enable it

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

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

Behavior & interactions

  • Chrome flag: it only renders its control when the matching enable* behaviour is on.