Theming
The pivot table draws every colour, space, radius and shadow from a --pivot-*
CSS variable. You choose a look in one of four ways, from the least work to the
most control: a ready-made colour scheme, the built-in dark look, a theme
object with your own colours, or the variables themselves.
One look for both grids
The pivot table takes the same palette and dark props as the
DataGrid, and the 36 colour schemes exist for both
under the same ids, so a page that shows both colours them with one setting:
import '@kanunilabs/datagrid-react/styles.css';
import '@kanunilabs/datagrid-react/themes/porcelain.css';
import '@kanunilabs/pivotgrid-react/styles.css';
import '@kanunilabs/pivotgrid-react/themes/porcelain.css';
<DataGrid palette="porcelain" … />
<BasePivotGrid palette="porcelain" … />
The DataGrid's six classic palettes (nord, dracula, solarized, gruvbox,
catppuccin, tokyo-night) are part of its own stylesheet and have no pivot
counterpart; for a matched pair, use the schemes.
A scheme you build in the Theme Builder works the same way: it exports one stylesheet per grid under the name you give it. In a shadcn/ui app the grids can follow your shadcn variables instead, dark mode included — see Tailwind CSS and shadcn/ui.
Colour schemes
Both packages ship 36 colour schemes, light and dark, each one a small
stylesheet next to the grid's own. Import the one you want after
styles.css and name it with palette:
import '@kanunilabs/pivotgrid-react/styles.css';
import '@kanunilabs/pivotgrid-react/themes/graphite.css';
<BasePivotGrid gridId="sales" data={data} initialFields={fields} palette="graphite" />
The plain JavaScript package has the same files and the same option:
import '@kanunilabs/pivotgrid/styles.css';
import '@kanunilabs/pivotgrid/themes/graphite.css';
createPivotGrid(host, { data, initialFields: fields, palette: 'graphite' });
The grid marks its root with data-theme="graphite", and every popup it opens
(field menus, the filter list, dialogs, the field chooser, the drill-down)
carries the same mark, so the scheme reaches all of them. themes/all.css
holds every scheme at once, for an app that lets its users choose. Earlier
versions named the scheme with theme={{ id: 'graphite' }}; that still works,
and palette wins when both are given.
Dark
dark switches to the built-in dark look — the DataGrid's own dark palette,
so the two components match side by side:
<DataGrid dark … />
<BasePivotGrid dark … />
A colour scheme decides its own mode: with palette set, dark has no
effect. For a dark scheme other than the built-in one, pick a dark palette
(graphite, midnight, onyx…).
Your own colours
The theme object sets colours from code. Anything in it wins over a scheme
and over dark, so a scheme can be the starting point for a brand colour:
<BasePivotGrid … palette="graphite" theme={{ primary: '#f59e0b' }} />
theme field | Variable | Paints |
|---|---|---|
background | --pivot-bg | The page under the data cells (they are transparent) |
surface | --pivot-surface | Panels, menus, dialogs |
surfaceHover | --pivot-surface-hover | Hovered rows, menu items |
surfaceHeader | --pivot-surface-header | The filter area, field areas, footer, dialog headers — and the column headers unless headerBackground is set |
headerBackground | --pivot-header-bg | The column-header band alone |
headerText | --pivot-header-text | Text on the column-header band |
border | --pivot-border | Grid lines and panel borders |
text | --pivot-text | Body text |
textMuted | --pivot-text-muted | Secondary text, placeholders |
textHeader | --pivot-text-header | Header text on the panels |
primary | --pivot-primary | The accent: buttons, focus, active toggles |
primaryForeground | --pivot-primary-foreground | Text on the accent |
success | --pivot-success | Success as text and icons |
danger | --pivot-danger | Errors, as text and icons |
warning | --pivot-warning | Warnings |
info | --pivot-info | Notes |
totalBackground | --pivot-total-bg | Total and subtotal rows |
stripeBackground | --pivot-stripe-bg | Alternate rows with striped |
groupBorder | --pivot-group-border | The rule between header groups |
iconActive | --pivot-icon-active | An icon that is switched on (an active filter) |
For a dark header band over light panels, give the band its own pair:
theme={{ surfaceHeader: '#f1f5f9', headerBackground: '#1e293b', headerText: '#f8fafc' }}
Try the presets live in the Theming playground.
Density
density sets the row rhythm and changes no colours, so it combines with any
scheme: 'compact' (24px rows), 'normal' (28px, the default) or
'comfortable' (36px). Details in Features → Density.
Typeface and numbers
The grid inherits the page's font. To give it, and every popup it opens, a
font of its own, set --pivot-font-family once:
:root {
--pivot-font-family: 'Inter', system-ui, sans-serif;
}
A font set only on the grid's container would not reach the menus and dialogs,
which are portalled to <body>; the variable does. The DataGrid reads
--dg-font-family the same way. Data cells use equal-width digits
(font-variant-numeric: tabular-nums), so amounts line up column by column in
any font.
The variables
Set these on .kanuni-pivot-root — or on .kanuni-pivot-root[data-theme="<your-id>"]
for a named look — and the grid and its popups pick them up.
Colours
| Variable | Default | What it paints |
|---|---|---|
--pivot-bg | #ffffff | The page under the data cells |
--pivot-surface | #ffffff | Panels, menus, dialogs |
--pivot-surface-hover | #f3f4f6 | Hovered rows and items |
--pivot-surface-header | #f8fafc | Filter area, field areas, footer, dialog headers |
--pivot-header-bg | --pivot-surface-header | The column-header band |
--pivot-header-text | --pivot-text-header, else --pivot-text | Text on the band |
--pivot-text-header | — | Header text on the panels |
--pivot-border | #e2e8f0 | Grid lines, panel borders |
--pivot-border-strong | #94a3b8 | Resize grips, stronger rules |
--pivot-text | #0f172a | Body text |
--pivot-text-muted | #64748b | Secondary text |
--pivot-primary | #0ea5e9 | The accent |
--pivot-primary-foreground | #ffffff | Text on the accent |
--pivot-primary-hover | #0284c7 | The accent under the pointer |
--pivot-success | #22c55e | Success as text and icons |
--pivot-success-bg | #15803d | A success fill — a "saved" mark, a badge |
--pivot-success-foreground | #ffffff | Text on the success fill |
--pivot-danger | #ef4444 | Errors |
--pivot-warning | #f59e0b | Warnings |
--pivot-info | #3b82f6 | Notes |
--pivot-total-bg | — | Total and subtotal rows |
--pivot-stripe-bg | — | Alternate rows with striped |
--pivot-group-border | — | The rule between header groups |
--pivot-icon-active | — | An icon that is switched on |
--pivot-control-accent | auto | Native check boxes and radio buttons |
--pivot-overlay-bg | rgba(0, 0, 0, 0.5) | The backdrop behind a dialog |
--pivot-chooser-overlay-bg | rgba(0, 0, 0, 0.4) | The field chooser's lighter backdrop |
--pivot-modal-bg | --pivot-surface | Dialog panels |
Type — --pivot-font-family (unset: the page's font), --pivot-text-xs
(11px), --pivot-text-sm (13px), --pivot-text-base (14px), --pivot-text-lg
(16px), --pivot-text-xl (18px).
Spacing — --pivot-space-0 to --pivot-space-12: 0, 4, 6 (-1-5), 8, 12,
16, 20, 24, 32 and 48px.
Radii — --pivot-radius-none, -sm (4px), -md (6px), -lg (8px), -xl
(12px), -full; --pivot-border-radius is the one most controls use (-md).
Elevation — --pivot-shadow-none, -sm, -md, -lg, -xl, -inset (a
pressed toolbar toggle) and -menu (field and view menus).
The colour schemes set the colour variables only, measured for contrast (body text 4.5:1 on every ground a cell can have); the type, spacing, radius and elevation variables are yours to change.
Next to the DataGrid
The two components use their own prefixes so they can be themed side by side without collisions. The everyday pairs:
| DataGrid | PivotGrid |
|---|---|
--dg-bg | --pivot-bg |
--dg-surface | --pivot-surface |
--dg-surface-header | --pivot-surface-header |
--dg-header-bg / --dg-header-text | --pivot-header-bg / --pivot-header-text |
--dg-border | --pivot-border |
--dg-text / --dg-text-muted | --pivot-text / --pivot-text-muted |
--dg-primary / --dg-on-primary | --pivot-primary / --pivot-primary-foreground |
--dg-success / --dg-success-text / --dg-on-success | --pivot-success-bg / --pivot-success / --pivot-success-foreground |
--dg-danger-text | --pivot-danger |
--dg-font-family | --pivot-font-family |