SpreadsheetGrid
Guides

Choose the features you bundle (/lite)

Bundle only the features you use with createSpreadsheetGrid, cutting the initial JS about in half

SpreadsheetGrid includes every feature, and its initial JS is about 236KB (gzip). With createSpreadsheetGrid from @ishibashi0112/spreadsheet-grid/lite, you can build a grid with only the features you pass. Code for features you don't pass doesn't go into the bundle.

/lite was added in 0.54.0.

The Solid version has no /lite entry. Import createSpreadsheetGrid and the feature parts (standardFeatures / findFeature and so on, with the same names) from the main entry @ishibashi0112/spreadsheet-grid-solid, and the bundler drops unused parts and the full SpreadsheetGrid (about 128KB with no features, about 157KB with standardFeatures, about 257KB for the full build; solid-js not included). The code on this page shows the Solid version in the Solid tabs.

import { createSpreadsheetGrid, standardFeatures } from '@ishibashi0112/spreadsheet-grid/lite';
import '@ishibashi0112/spreadsheet-grid/style.css';

// create it once at the top of the module (not inside a component)
const Grid = createSpreadsheetGrid({ features: standardFeatures });

export function OrdersTable() {
  return <Grid rows={rows} columns={columns} rowKeyGetter={(row) => row.id} />;
}

Grid takes the same props, ref handle and types as SpreadsheetGrid. To move from the full build, put the features you use in features, and replace SpreadsheetGrid with the component created by createSpreadsheetGrid.

Try it

Choose features, and the grid switches to one built with that combination. Props for every feature are passed so that differences between any features are visible, so nothing happens for features not included. The description to the right of each feature tells you how to try it.

Loading…

How much smaller

SetupInitial JS (gzip)
Full build (SpreadsheetGrid)About 236KB
/lite with no featuresAbout 119KB
/lite + standardFeaturesAbout 145KB
/lite + standardFeatures + serverSideFeatureAbout 150KB

Measured with esbuild minification and React externalized (including @tanstack/virtual-core). It varies by a few KB per bundler (measuring the 0.61.0 full build, Vite 8 (Rolldown) was about 1.5KB smaller than esbuild and Vite 7 (Rollup) about the same; in Next.js 16, webpack was about 4KB larger than Turbopack). How much each feature adds is in the table in the API reference.

Choosing features

Even with no features, display (virtual scrolling, pinned columns), selection, keyboard operation, editing, copy / paste, undo, column resizing, sorting, row selection, detail rows and getState / applyState work. Add the features you need on top as { key: part }. A part's name is "the key + Feature".

import {
  createSpreadsheetGrid,
  standardFeatures,
  findFeature,
  serverSideFeature,
} from '@ishibashi0112/spreadsheet-grid/lite';

// add find and SSRM to the preset
const Grid = createSpreadsheetGrid({
  features: { ...standardFeatures, find: findFeature, serverSide: serverSideFeature },
});

Feature combinations can be put in variables and exported. Even with declaration: true, in a shared in-house component package and so on, you don't need to annotate the type (since 0.65.0; up to 0.64.0 the type GridFeatures annotation was needed, and without it you got TS2742 / TS2883). If you annotate, use GridFeatures. Putting a part under a different key is a type error.

import type { GridFeatures } from '@ishibashi0112/spreadsheet-grid/lite';

export const companyFeatures = { ...standardFeatures, find: findFeature };
// annotating is fine too
export const searchOnlyFeatures: GridFeatures = { find: findFeature };

Notes for distributing it as a library are in Versioning and compatibility.

  • standardFeatures is column filters / the global filter (filtering), the column menu (columnMenu), the tool panel (toolPanel), column auto-sizing (columnAutosize) and export (export).
  • The way to sort from column headers is the column menu. Without the column menu, the only way to sort on screen is the "Sort" tab of the tool panel (toolPanel) (with neither, only from APIs like applyState).
  • The way to apply column filters on screen is "Filter…" in the column menu. With filtering alone only the search box works, so to use column filters too, add columnMenu as well.
  • The tool panel (toolPanel) opens from column menu items and active filter chips. Add it together with columnMenu or filtering (with neither, there's no way to open it, so it does nothing).
  • "Auto-size width" in the column menu appears only when columnAutosize is added.
  • Features on by default in the full build (column filters, the column menu, column drag, selection aggregates, the dotted line around the copied range and so on) are on by default in /lite only when added.

Moving from the full build

Some features work in the full build without writing a prop, and disappear in /lite unless added. No prop is passed, so no development warning appears either. For the same default behavior as the full build, add all the features in this table.

Features that work in the full build without writing a propKeystandardFeatures
Column filters / the global filterfilteringIncluded
Column menucolumnMenuIncluded
Tool panel (opened from column menu items)toolPanelIncluded
Auto-sizing a column by double-clicking its bordercolumnAutosizeIncluded
Reordering by dragging column headers (when onColumnsChange is passed)columnReorderNot included
Selection aggregates (bottom bar)selectionAggregatesNot included
The dotted line around the copied range (after Ctrl/Cmd+C; the dotted line for cutting with Ctrl/Cmd+X is in the core and always shows)motionExtrasNot included
import {
  createSpreadsheetGrid,
  standardFeatures,
  columnReorderFeature,
  selectionAggregatesFeature,
  motionExtrasFeature,
  type GridFeatures,
} from '@ishibashi0112/spreadsheet-grid/lite';

// the same default behavior as the full build (remove features you don't use from here)
const features: GridFeatures = {
  ...standardFeatures,
  columnReorder: columnReorderFeature,
  selectionAggregates: selectionAggregatesFeature,
  motionExtras: motionExtrasFeature,
};
const Grid = createSpreadsheetGrid({ features });

Other features (find, the fill handle, row drag, SSRM and so on) work only when their prop is passed, so for any prop you pass, the development warning names the feature to add.

When you use a feature you didn't add

Passing a prop of a feature you didn't add, or calling its methods, does nothing (no error either). In development builds, once per prop that starts a feature (fillHandle / enableRowDrag / pinnedBottomRows and so on), a warning names the feature to add (finer settings that work on top of a feature, such as canDropRow / includeGroupingInState / pinnedBottomRowsPlacement, do nothing without a warning when the feature is missing) (export and the tool panel, which have no prop, warn when their methods such as exportCsv() / openFilterManager() are called; openFilterManager() opens the filters tab, so it also warns when filtering is missing). The warning is a Japanese line followed by an English line:

[spreadsheet-grid] prop `fillHandle` が渡されましたが、その機能が機能セットに入っていないため何もしません。createSpreadsheetGrid の features に `fillHandle: fillHandleFeature` を入れてください。
[spreadsheet-grid] prop `fillHandle` does nothing because its feature is not in the feature set. Add `fillHandle: fillHandleFeature` to features in createSpreadsheetGrid.

Production builds don't warn (the warning code is removed from the bundle entirely).

When sharing column definitions between a grid with filtering and one without, writing enableColumnFilter={false} on the one without avoids warnings about columns' filterType (it tells the grid those column definitions' filters aren't used).

Some features behave differently when missing.

  • Without filtering, the search box and column filters don't appear. Filters passed with applyState go into the state, but rows aren't filtered (not counted in "Filter: …" in the top / bottom bars either).
  • Without serverSide, dataSource is ignored and it works with rows.
  • Without labelRow, label rows line up as data rows too.
  • Without grouping, rowGroup columns are shown as is, without grouping.

Notes

  • Call createSpreadsheetGrid at the top of the module. Calling it inside a component makes a different component on every render, and the grid's state (selection, scroll position, values being edited and so on) is lost. When that happens, a development console.warn tells you (creating it once with useMemo doesn't warn, but eslint-plugin-react-hooks' static-components flags it, so the top of the module is recommended).
  • In Next.js (App Router), add 'use client' to the file that calls createSpreadsheetGrid. The created component and standardFeatures are functions, so they can't be passed as props from server components (import and use them inside client components).
  • The feature combination is fixed at creation. To add features later, switch to a component created with a different combination.
  • You can mix it with the full SpreadsheetGrid in the same app, but /lite is a separate build split into files per feature, so they don't share common parts. Using both on the same page includes the common parts twice (in esbuild measurements, about +33KB over the full build alone = about 153KB → about 186KB), and even on separate pages, pages using only /lite may get larger (measured with Next.js 16's Turbopack at 0.54.0, a standardFeatures page went from about 90KB to about 97KB). Stick to one of the entries.
  • Unused features being dropped from the bundle has been checked with Vite 8, webpack 5, Next.js 16 (default Turbopack) and esbuild (the bundler needs to understand sideEffects in package.json and /* @__PURE__ */).
  • In tests, import preloadGridPopups() for opening column filters or the tool panel from /lite (each entry has separate parts, so the one from the full entry doesn't load the parts of /lite grids; Testing). The Solid version has one entry, so the one from the main entry works for both grids.

On this page