GridColumn props
Column definitions (GridColumn<T>), filters, editors, validation, column widths and grouping
One reference for both the React and Solid versions
GridColumn props (GridColumn<T>)
| Name | Type | Default | Description |
|---|---|---|---|
key | string | (required) | The column's unique key. |
title | string | — | The header label. When unset / empty (''), key is shown (column names in the column menu / filter panel / CSV headers and so on fall back the same way). To leave the header blank, such as for a button-only column, pass a single space (' ') or similar. |
width | number | (required) | Column width (px). |
minWidth | number | — | Lower limit when resizing (when unset, the lower limit for manual resizing is 60px; 0 lets it shrink to 0). Also used as the lower clamp for flex distribution (if unset on a flex column, an internal default of 50px). |
maxWidth | number | — | Upper limit. No limit when unset (autoSize fits the content exactly and manual resizing can widen freely; there is no default limit). When set, it is the upper clamp for autoSize / manual resizing / flex distribution. |
flex | number | — | Grow ratio of center (non-pinned) columns. The leftover width (container width − row header − pinned total − total of fixed-width columns) is distributed by the flex ratio and clamped by minWidth/maxWidth. Distributed widths are whole px (fractions are cut and carried to the next column, so the total never exceeds the available width). It grows and shrinks reactively with the container. Manual resizing switches it to a fixed px width (fixed until that column's flex / pinned / width change or the columns are reset, then it goes back to flex). Ignored on pinned columns. On flex columns width isn't used (it isn't a minimum either; with no leftover width they shrink to the default lower limit of 50px). Write a width you don't want to shrink below as minWidth. Details in "flex and autoSize (how column widths are decided)" below. |
resizable | boolean | inherits the grid's enableColumnResize | Whether this column can be resized manually. false hides the header's resize handle. Double-clicking the resize handle autoSizes that column to its content (not possible with false since there is no handle; autoSize from the column menu still works). |
suppressAutoSize | boolean | false | true excludes it from autoSize (skipped by the column menu / boundary double click / auto-fit all columns). Keeps the consumer's width (fixed width wins). A per-column opt-in for custom UI columns that can't be measured by text or columns you want to show at a fixed width. |
estimateCellWidth | (row, column) => number | — | Width estimate for autoSize. For columns with it, "the cell's content width (px, without the cell's padding/border)" comes from this function and is settled as the maximum over all rows + the cell frame (no text / candidate / real DOM measurement, and no React mounting). An opt-in for renderCell custom UI columns (badges side by side and the like) whose text length doesn't correlate with the drawn width. Make the returned value match the actual drawn width of renderCell. |
autoHeight | boolean | — | This column drives the height of auto-height rows (only when the grid's autoHeight is on). Not covered by autoSize (it assumes wrapping; see the limits in "flex and autoSize" below). |
verticalAlign | 'top' | 'center' | — | Vertical alignment of this column's content in rows grown by auto-height (takes priority over the grid's verticalAlign). When unset, the grid's setting; if that is unset too, autoHeight columns are top and other columns centered. |
wordBreak | 'normal' | 'break-all' | 'keep-all' | 'break-word' | 'auto-phrase' | — | CSS word-break when wrapping (= autoHeight columns). 'auto-phrase' is phrase-based wrapping with BudouX in Chromium (Chrome / Edge) (not supported in Firefox / some Safari). No effect on nowrap (non-autoHeight) columns since they don't wrap at all. The default (unset) is the browser standard = character wrapping with line-breaking rules. Details in "Wrapping Japanese text (word-break / BudouX)". |
lineBreak | 'auto' | 'loose' | 'normal' | 'strict' | 'anywhere' | — | CSS line-break when wrapping (how strict the line-breaking rules are). 'strict' makes them stricter. Like wordBreak, only has an effect on wrapping columns. |
visible | boolean | — | Shows / hides the column. Even when hidden, column filters / sorts on that column keep narrowing / ordering rows (the quick filter = global search only covers visible columns). |
editable | boolean | true (unset = editable) | Whether this column can be edited. Columns without it are editable, and false or readOnly: true makes them read-only (the whole grid with readOnly, per cell with canEditCell). |
readOnly | boolean | — | Makes this column read-only. |
pinned | 'left' | 'right' | undefined = center scrolling | Which side to pin the column to. While the total width of pinned columns (including the row number column) is too wide to leave 120px for the center, pinning is lifted for display only, first from the innermost right pinned columns, then from the innermost left pinned columns, and they scroll in the center (pinned in columns doesn't change, and they pin again when there is room; because at phone widths the right pinned columns overlapped the left ones and the center couldn't be seen; since 1.0.1). When the total column width is narrower than the table, right pinned columns sit right after the center columns, not at the table's right edge (to put them at the right edge, give one of the center columns flex to fill the leftover width). |
rowGroup | boolean | — | true makes this column a row grouping key (with several, the order in the columns array is the hierarchy order). When on, the group source columns leave the display and an auto group column (tree display) is inserted first. clientSide only (ignored in serverSide, with a development warning). In tables where any column has rowGroup written (including false), the column menu shows "この列でグループ化" (group by this column) / "グループ化を外す" (ungroup) (onColumnsChange is needed; shown not only on columns with rowGroup but on every column except those with aggregates and the last data column). Details in "Row grouping and aggregation (rowGroup / aggFunc)". |
aggFunc | 'sum' | 'min' | 'max' | 'avg' | 'count' | GridAggFunc<T> | — | This column's aggregate when grouping and in the total row (totalRow). The built-ins count only numbers and numeric strings (empty values, whitespace-only strings, true / false, Date, arrays and so on are excluded; count is the number of leaf rows below / in the total row, the number of target rows). A function gives a custom aggregate (its return value shows in group rows / the total row). With tree data (treeData), cells of this column in rows with children show the aggregate of the leaf rows below (since 1.9.0; see "Tree data (treeData)"). Ignored when there is no rowGroup column, totalRow or treeData. |
groupLabel | 'value' | 'formatted' | CellValueFormatter<T> | 'value' | The heading text of row grouping group rows (since 1.1.0). 'value' is the value's text (the same as up to 1.0), 'formatted' the column's valueFormatter (the same display name as cells; the value's text if none), and a function its return value (row is the group's first row). Blank groups stay "(空白)" (blank). Subtotal row headings in exports follow the same rules as copy (formatClipboardValue). Details in "Columns whose value and label differ". |
exportable | boolean | true | false leaves this column out of CSV / TSV export (exportCsv / downloadCsv, including scope 'selection') and getExportData (since 1.3.0). Use it for columns of action buttons or internal-only IDs. Copying a selected range (Ctrl/Cmd+C) includes it as before (copies what you selected). To leave out rows, use the isRowExportable prop. |
selectionAggregate | boolean | true | false keeps this column's cells out of the sum / average of selection aggregates (showSelectionAggregates) (and the min / max of slotContext.selectionAggregates). They are still counted in the count (since 1.2.0). Use it for columns of digit strings that aren't numbers, such as JAN codes, postal codes and employee numbers. Has no effect on group aggregates and the total row (aggFunc). |
getValue | (row: T) => unknown | row[key] | Value accessor. Writing to a column without setValue puts the value in row[key], and the display (getValue) doesn't change. For computed columns, use editable: false or pass setValue (in development, one console.warn per column that added a property not on the row). |
setValue | (row: T, value: unknown) => T | — | Value writer (returns a new row). |
renderCell | (ctx: CellRenderContext<T>) => ReactNode | a plain <span> | Custom cell rendering. With the detailRow prop, ctx.detail ({ expanded, expandable, toggle, setExpanded }) lets you place the expandable row toggle yourself. |
align | 'left' | 'center' | 'right' | 'left' | Horizontal alignment of cell content (display only; the value is unchanged). Applies to the cell display and the edit input. |
headerAlign | 'left' | 'center' | 'right' | same as align | Horizontal alignment of the column header (follows align when unset; set it on columns where only the header should differ). 'right' mirrors the layout (sort arrows and the filter mark go left of the label, and the hover grip and ⋮ go left too). 'center' centers only the text, with marks and actions on the right (when a mark shows, centered within the width excluding the mark). It also applies to renderHeader content (the container's text-align). The header width used by column auto-fit doesn't change. |
valueFormatter | (params: CellValueFormatterParams<T>) => string | — | Formats the displayed cell value (display only). Default cells without renderCell show its return value. Built-ins such as numberFormatter can be passed. Doesn't affect the raw value / editing / copy / sort / filter (the global filter can use it with globalFilterMatch, and group row headings with groupLabel: 'formatted'; since 1.1.0). It also formats group row aggregates and total row values; there is no source row then, so row is undefined (typed T | undefined; write row?.x when reading row). |
cellClassName | GridSlotProps | ((ctx: CellStyleContext<T>) => GridSlotProps | undefined) | — | Extra classes on the cell (conditional styling). GridSlotProps = string | { className?, style? }, so you can return StyleX's stylex.props(...) as is (style is applied inline to the cell; the grid's position / size win). The function form can return per value / state. ctx has the view rowIndex plus source-based sourceRowIndex / rowKey (so you can match data by source row even with sorting / filtering on; see "Helper types"). The base .ssg-body-cell is unlayered with specificity (0,1,0). For a reliable override, chaining .ssg-body-cell.my-class is recommended. |
cellNote | (ctx: CellStyleContext<T>) => string | null | undefined | — | A cell note (like FarPoint SPREAD's cell memo / Excel's notes). Cells that return a string get a mark at the top right (a 10px triangle; color from the token --ssg-note-indicator), and hovering shows the string in a tooltip (\n breaks lines). undefined / null / an empty string (only whitespace) shows nothing. ctx is the same as the function form of cellClassName. On a cell with an input error too (validate's mark), the error's 6px red triangle sits on top of the note's triangle so both show, and the tooltip is "error → line break → note". Evaluated only for rendered cells (the same cost class as the cellClassName function). Not included in CSV / TSV / the clipboard / getExportData. Details in "Cell notes (cellNote)". |
conditionalFormat | GridConditionalFormat<T> | — | Conditional formatting. Overlays a value's "amount" / "direction" / "state" on the default cell rendering. dataBar (a background bar; when min / max are omitted, computed from the numbers of view rows = after filtering / sorting; negative values go left from the 0 axis. color / negativeColor / showValue: false for the bar only) / colorScale (tints cell backgrounds in steps; type: 'sequential' (default; light → dark) / 'diverging' (mid as the neutral color with the negative / positive sides in different hues; replace the color steps with colors)) / chips (a map from value → tone 'neutral' | 'info' | 'good' | 'warning' | 'critical' or { tone, label, icon, color }, or a function returning one from ctx; an icon + label pill). Several can be set at once. Display only; doesn't affect export / copy / sort / filter. Colors are the --ssg-cf-* tokens. Details in "Conditional formatting (conditionalFormat)". |
renderHeader | (ctx: HeaderRenderContext<T>) => ReactNode | — | Custom header rendering. Pressing buttons / inputs / links and the like placed inside (button / input / select / textarea / a[href] / label / contenteditable / role="button" and so on) doesn't start a column range selection (the default action isn't stopped either, so inputs get focus). Pressing other parts selects the column as before. On narrow columns (under 120px), while the pointer is over a button or similar inside, the actions that appear on hover (the sort grip / the column menu ⋮) are hidden so that the button inside, not an action on top of it, gets the press (since 1.3.0; on the empty part of the header they appear as before). |
filterType | 'text' | 'textSet' | 'number' | 'numberSet' | 'date' | 'dateSet' | 'select' | 'set' | 'custom' | 'auto' | — | Kind of filter UI. 'auto' is an opt-in that picks numberSet / textSet / dateSet from the column's values (see "filterType: 'auto' (automatic)" below). 'numberSet' / 'textSet' / 'dateSet' are combined filters that stack a condition (operator + value) and a Set list vertically in one popover and combine them with AND (applying a condition narrows the Set candidates along with it; selections of values that drop out of the candidates are kept, not discarded). The numberSet list is in numeric order (non-numbers after it, blanks last; candidates passed with filterOptions / getFilterOptions keep the order you passed). numberSet operators are ≥ / > / ≤ / < / equals / does not equal / range / blank / not blank, and textSet operators are contains / equals / starts with / ends with / blank / not blank (case-insensitive). dateSet has range / on or after / on or before / equals / does not equal / blank / not blank + relative presets (today / this month / last 30 days; saved as relative and resolved at every evaluation), and its Set part is a three-level year / month / day tree (parents have tri-state checks). |
filterOptions | readonly GridSelectFilterOption[] | collected from rows | Candidates for select / set / numberSet / textSet / dateSet (readonly / as const arrays are fine). |
dateFilterPresets | false | DateFilterPresetOption[] | the 3 built-ins | Which relative preset chips dateSet shows. false / [] hides the chip row (opt-out). An array can mix built-in IDs ('today' / 'thisMonth' / 'last30days') and custom definitions { id, label, resolve } in display order. Details in "Relative presets for dateSet (dateFilterPresets)" below. |
filterFn | (row: T, filterValue: unknown) => boolean | — | Custom filter predicate. filterValue isn't the entered value itself but the column's filter descriptor (ColumnFilterValue): { kind: 'custom', value: entered string } with filterType: 'custom', and the shape of that kind for other kinds (the same as "Column filter wire format"). When set, it takes priority over the built-in check for every filterType. The filter screen for filterType: 'custom' is one text input (the same screen as text, with the same text "部分一致で絞り込み" (filter by partial match)), and without filterFn it narrows by partial match. |
editor | GridColumnEditor<T> | like text | Cell editor kind (discriminated union). { type: 'text' | 'number' | 'select' | 'date' | 'time' | 'datetime' | 'checkbox' | 'custom', ... } (time / datetime since 1.11.0). Use editorForRow to vary it per row. Details in "Cell editors (editor)". |
editorForRow | (row: T) => GridColumnEditor<T> | undefined | — | Per-row editor (since 1.11.0). The returned editor beats editor, and rows that return undefined use editor. Places without a row (such as column filter filterType: 'auto' inference) use editor. Called during rendering, so keep it pure and light (like the function form of select's options). Details in "Per-row editors (editorForRow)". |
validate | (ctx: CellValidationContext<T>) => CellValidationResult | — | Validates the cell value. true = valid / false = invalid (default message) / string / { message } = invalid + message. Keep it pure and light (evaluated for every visible cell on every render; the same cost class as the cellClassName function). The number editor's min / max / integer checks run after validate (a validate failure keeps its message; only values it passes get the built-in checks). Details in "Validation (validate / validationMode)". |
validationMode | 'mark' | 'reject' | 'mark' | What happens when validation fails. 'mark' = the value goes in but the cell shows as invalid / 'reject' = the write itself is refused. |
parseClipboardValue | (raw: string, row: T) => unknown | the editor's default parser | A "string → cell value" parser (shared by paste / clear / editor commit). An explicit one always wins. When unset and editor is number / date / checkbox, the kind's default parser is supplied automatically (see the table in "Cell editors (editor)"). To add currency symbols and the like to the number default's reading, use the built-in numberParser({ strip }) (since 1.1.0; see "Values that can't be read when pasting (numberParser / onPasteSkipped)"). |
formatClipboardValue | (value: unknown, row: T) => string | — | Formatter for copying (also for CSV / TSV and getExportData's text). When unset, select editor columns with clipboard: 'label' give the candidate's label (since 1.1.0). |
filterType: 'auto' (automatic)
With filterType: 'auto', the effective kind (numberSet / textSet / dateSet) is decided from the column's values. Explicit opt-in only: columns without filterType still have "no filter" as before (the default doesn't change).
- When it decides: once, the first time that column's popover opens, and then it stays fixed for that column (if the kind wavered as rows are added / edited, the applied filter descriptor and the UI would disagree). If there was nothing to decide from (rows still empty and so on), it isn't settled and is decided again the next time it opens.
- Priority: ① the
kindof an applied filter descriptor (when a value is already there, restored withapplyState) → ② the previous decision → ③ a hint from theeditorkind ({ type: 'number' }→ numberSet /{ type: 'date' }→ dateSet; reliable and fast since it doesn't look at values) → ④ sampling values. - Sampling: up to 1,000 non-blank cells from the top (the scan stops at 20,000 rows). It is strict: if every sample can be read as a date,
dateSet; if every sample can be read as a number,numberSet; if even one doesn't fit,textSet(the safe side). - The criterion is "can it be read", not the value's type: even if the DB type is a string,
'1234'counts as a number and givesnumberSet(consistent with how filter checks convert numbers). However, values with leading zeros (part codes and postal codes like'0001') don't count as numbers (the same as Excel).boolean/ objects don't count as numbers either. - serverSide: the client doesn't have all rows, so it doesn't infer from values. With an
editorhint it decides by that; otherwise it falls back to'text'(a condition-only partial match filter). When using auto, setting theeditorkind is recommended.
Relative presets for dateSet (dateFilterPresets)
The relative preset chips in the filterType: 'dateSet' popover (default: today / this month / last 30 days) can be configured per column with the column option dateFilterPresets.
// ① Hidden (opt-out): no chip row at all
{ key: 'updatedAt', filterType: 'dateSet', dateFilterPresets: false }
// ② Custom setup: built-in IDs and custom definitions can be mixed in display order
{
key: 'updatedAt',
filterType: 'dateSet',
dateFilterPresets: [
'today', // built-in ID (the label is the default "今日" (today))
{
id: 'thisWeek', // this id is what gets saved (stays relative)
label: 'This week',
resolve: (now) => { // called at every evaluation and resolved to an absolute range
const day = now.getDay();
const monday = new Date(now.getFullYear(), now.getMonth(), now.getDate() - ((day + 6) % 7));
return { from: monday, to: now }; // 'YYYY-MM-DD' strings or Date (both ends inclusive)
},
},
],
}- Same "saved as relative" semantics as the built-ins: only
{ mode: 'preset', preset: id }is saved in the filter value, and at every evaluation (filter recomputation) it is resolved to an absolute range withresolve(now). RestoringgetState()state the next day makes the range follow, and when the date changes while the grid is open it resolves again automatically (only while a relative preset is applied, it watches for midnight, and when the timer is late after sleep and the like it checks again when the tab comes back to the front. It filters again only on days when the resolved range changes, and serverSide refetches blocks; for "this month", only when the month changes. Even with the column filter popup open, the value tree and "一致 N 件" (N matches) move to the new day = since 1.3.0). The watch timer is re-armed at most every hour, so when using fake timers in tests, advance them withadvanceTimersByTimeand the like, notrunAllTimers. resolvereturns{ from?, to? }(both ends inclusive). With only one side it means on or after / on or before, andfrom > tois swapped automatically when evaluated. Omitting both means "no condition". It works in days (if you return aDate, the time is dropped and it compares as that date). Time ranges like "the last hour" can't be made, so to narrow by time usefilterType: 'custom'+filterFn.- Saved values with IDs removed from the column definition are evaluated as "no condition" (the safe side, avoiding accidents where every row disappears). The summary label falls back from the configured label → the built-in default label → the raw ID.
- serverSide: custom IDs are passed to the dataSource as
{ mode: 'preset', preset: id }too. Interpreting them (id → WHERE clause) is the server's job (see "serverSide mode (SSRM)").
Date input for dateSet (default UI)
The date input of dateSet filter conditions is not the native <input type="date"> but an in-house date field (to avoid looks and behavior differing between browsers).
- Free input: accepts the same forms as typing into a cell's date editor, such as
2026/7/1/2026-07-01/2026.7.1/2026年7月1日/ full-width digits and symbols (2026/7/1) (since 1.3.0; before that only the/and-forms), and normalizes to'YYYY-MM-DD'on Enter / blur. Input that can't be read stays with a red frame (aria-invalid) and isn't committed (the applied condition is kept). - Calendar: the button at the right of the field opens / closes it. Clicking the title drills up day → month list → year list, and choosing a year / month goes back down a level (12 years / page). The footer of the month and year views also has "← 戻る" (back) to go up one level without choosing. Today has an outline and the selected day is filled. The footer has "今日" (today) and "クリア" (clear). Choosing a day commits at once and closes.
- Escape: while the calendar shows, closes only the calendar; when hidden, closes the popover (keeping the previous behavior).
- It follows the dark theme / compact density tokens. The calendar is drawn inside the popover, so it doesn't affect outside-click detection or keeping the popover on screen.
- The cell editor
editor: { type: 'date' }is still the native input (out of scope). - How date cell values are read (shared by filters / candidates / conditional formatting):
Dateinstances use the year, month and day in the browser's local time, and strings use the leadingYYYY-MM-DD/YYYY/M/Dpart as is (a trailing time / time zone isn't looked at).new Date('2026-07-01')is midnight UTC, so in time zones behind UTC (the US and so on) the local date is the day before (2026-06-30). When you receive dates only from a server, putting them inrowsas strings without converting toDateis the reliable way.
Replacing the date input (renderFilterDateInput)
A grid-level slot that replaces the date input of dateSet filter conditions (by default the in-house field above) with a picker from your UI library. It covers only the condition fields of the filter popover (not the cell editor editor: { type: 'date' }).
type FilterDateInputContext = {
value: string; // 'YYYY-MM-DD' or '' (empty)
onChange: (value: string | Date | null) => void; // Date / null (clear) / loosely written strings are fine too (normalized inside)
ariaLabel: string; // '開始日' (start date) / '終了日' (end date) / '条件の日付' (condition date)
slot: 'single' | 'from' | 'to'; // from/to of a range, or a single value
columnKey: string; // for varying it per column
};Mantine (@mantine/dates) example:
import { DatePickerInput } from '@mantine/dates';
<SpreadsheetGrid
renderFilterDateInput={({ value, onChange, ariaLabel }) => (
<DatePickerInput
aria-label={ariaLabel}
value={value || null} // v7 uses the Date type, so new Date(`${value}T00:00:00`)
onChange={onChange} // string | Date | null can be passed as is
valueFormat="YYYY/MM/DD"
size="xs"
clearable
popoverProps={{ withinPortal: false }} // ★ draw inside the popover (see the outside-click note below)
style={{ flex: 1, minWidth: 0 }}
/>
)}
/>HeroUI example (adjust prop names to your version):
import { DatePicker } from '@heroui/react';
import { parseDate } from '@internationalized/date';
renderFilterDateInput={({ value, onChange, ariaLabel }) => (
<DatePicker
aria-label={ariaLabel}
value={value ? parseDate(value) : null}
onChange={(date) => onChange(date ? date.toString() : null)} // CalendarDate → 'YYYY-MM-DD'
size="sm"
/>
)}Generic example (your own, with Tailwind and the like):
renderFilterDateInput={({ value, onChange, ariaLabel }) => (
<input
type="date"
aria-label={ariaLabel}
value={value}
onChange={(event) => onChange(event.target.value)}
className="my-date-input"
/>
)}Outside clicks (important): the filter popover "closes on an outside pointerdown", so if the picker's calendar goes to a portal directly under body, using the calendar closes the popover. Use one of these:
- Disable the portal and draw inside the popover (recommended): for Mantine,
popoverProps={{ withinPortal: false }}and the like. Height changes are handled automatically by the popover's measured resize support. - Opt out with the keep-open attribute: adding the
data-ssg-filter-keep-openattribute to the popup element (or an ancestor) keeps pointerdown inside it from closing the popover (most libraries let you passdata-*to popups).
Other notes:
- Values always go into the draft normalized to
'YYYY-MM-DD'/''(Date/'2026/7/1'and the like are fine; values that can't be read count as clearing). - Changing the value deselects the preset chip (the same rule as the native UI).
- The keyboard wiring for Enter to apply / Escape to close is for the native input only. Key handling on the slot side is the component's job (dateSet applies immediately, so usually no wiring is needed).
Value formatter (UI display)
valueFormatter changes only the displayed text of cells (the raw value, editing, copy, sort and filter keep the raw value). Import built-in factories (such as numberFormatter below) from the package entry. You can write your own with the same contract (CellValueFormatter<T>) (dates / percentages / currency and so on).
numberFormatter(options?)— formats numbers with thousands separators. By default it keeps the original precision (doesn't round decimals on its own). Fix the decimals withminimumFractionDigits/maximumFractionDigits, turn off separators withuseGrouping: false, and setlocaleif needed.null/undefined/''showemptyText(default''), and values that can't become numbers show the original value's text as is. One made without a type argument (const amount = numberFormatter()) can be reused in columns and grids with different row types. The returned function's type is(params: { readonly value: unknown; readonly [key: string]: unknown }) => string(since 1.3.0; it can be passed to any column'svalueFormatter, and when a library exports the result with its inferred type, the d.ts needs no core type names).
Example:
import { numberFormatter } from '@ishibashi0112/spreadsheet-grid';
const columns = [
{ key: 'amount', title: 'Amount', width: 140, align: 'right', valueFormatter: numberFormatter() },
];Values that can't be read when pasting (numberParser / onPasteSkipped)
Cells with Excel currency formats ("¥12,000", "12,000円", "(1,200)") can't be read as numbers by the number column's default parser. Text that can't be read goes in as text. If there is the number editor's min / max / integer / strict (1.2.0) or a column validate, columns with validationMode: 'mark' (default) get a mark and 'reject' columns don't write it (columns with none of these take it as is without a mark). Since 1.1.0, two things handle this.
numberParser(options?)— makes a "string → number" parser that reads the same way as the number editor's default parser (empty / whitespace-only isnull, full-width digits, signs, decimal points and thousands separators are read, and text that can't be read stays as the original text). Pass it to the column'sparseClipboardValue(shared by paste / Delete / editor commit).striplists characters to remove first (currency symbols or units), andnegativeParentheses: truereads numbers in parentheses ((1,200)/(1,200)) as negative.onPasteSkipped— reports cells a paste didn't write (cells that can't be edited, and values failing validation in'reject'columns), once per paste. Use it to show the count in a toast, list the messages and so on.
import { SpreadsheetGrid, numberParser } from '@ishibashi0112/spreadsheet-grid';
const columns: GridColumn<Expense>[] = [
{
key: 'amount',
title: 'Amount',
width: 120,
align: 'right',
editable: true,
editor: { type: 'number', min: 0 },
validationMode: 'reject',
parseClipboardValue: numberParser({ strip: ['¥', '¥', '円'], negativeParentheses: true }),
},
];
<SpreadsheetGrid
columns={columns}
onPasteSkipped={({ cells }) => {
toast(`${cells.length} cells weren't written`); // cells[i].reason: 'readOnly' | 'invalid'; message is the validation message
}}
...
/>;- Like
numberFormatter,numberParsercan be reused without a type argument ((raw: string) => unknown). cellsofonPasteSkippedare in the order of the pasted text (left to right, row by row).rowIndexis the view row (position after filtering / sorting) androwKeytherowKeyGettervalue. In serverSide (dataSource), cells of loaded rows are reported (written cells go toupdateRows). Cells the fill handle orDeletedidn't write aren't included.- Empty text pasted into cells that can't be edited (empty cells in an Excel range) isn't put in
cells(since 1.3.0). A paste with no writable cell at all doesn't callonRowsChangeand isn't added to undo (no rows / columns are added at the end of the table either; cells of rows / columns that weren't added are outside the table, so they aren't incellseither).
Cell editors (editor)
column.editor sets a column's editor kind (unset = text). It is the discriminated union GridColumnEditor<T>, and each kind's extra options are enforced by the types. Whether editing is allowed is decided by editable / readOnly / canEditCell as before (editor is only the kind).
| type | UI / interaction | Options | Default parser (when parseClipboardValue is unset) |
|---|---|---|---|
'text' | The plain text input (default). multiline: true gives a multiline input (a textarea; grows down with its content, stops at the bottom of the table's visible area and scrolls inside; line spacing, the first line's position and wrapping = the column's wordBreak / lineBreak match the cell) | multiline / enterKey (Enter with multiline: 'commit' (default, the same as Excel) = Enter commits, Alt+Enter and Ctrl / ⌘+Enter insert a line break / 'newline' (closer to notepads and chats) = Enter (also with Shift / Alt) inserts a line break, Ctrl / ⌘+Enter commits. Smartphone on-screen keyboards can't press Alt / Ctrl, so for columns that need line breaks on mobile use 'newline' (commit by focus out)) | Pass-through (the raw string) |
'number' | <input type="number"> (spinner / ↑↓ steps / blocks invalid characters). When you select a cell and start typing with - / + / ., it opens as a text input (inputmode="decimal") so the character isn't lost, and the committed string is turned into a number by the column's parser (-5→-5, .5→0.5, just - is empty; strings that can't be read as numbers stay as is, as with paste). When you start typing with a character that isn't a number such as a letter, or open a value that is a non-numeric string, it also opens as a text input and shows that text as is. Values that are numeric strings ('1,234' / '12') open as half-width numbers (1234 / 12) | min / max / step / integer (min / max / integer are used for value checks too; see "Validation (validate / validationMode)") / strict (true marks values that can't be read as numbers; 1.2.0) | '', whitespace only → null / finite numeric strings → number (full-width digits, signs, decimal points and thousands separators are read too: '1,234'→1234, 'ー5'→-5) / non-numeric → the raw string (mark catches it) |
'select' | A candidate dropdown (in a portal outside the table; popupContainer). ↑↓ = move the highlight / Enter = commit (down) / Tab = commit (left / right) / click = commit / printable keys = type-ahead by label prefix (resets after about 700ms) / text confirmed with the IME (Japanese names and so on) = candidates starting with that text, or containing it if none (1.0.2). search: true columns filter as you type (the cell becomes an input with the candidate list below; since 1.7.0; see "Searchable select editor (search / loadOptions / fillRow)") | options: readonly GridSelectEditorOption[] | (row) => readonly GridSelectEditorOption[] (static or per row; the function is called during rendering, so keep it pure; readonly / as const arrays are fine; since 1.3.0) / clipboard: 'value' | 'label' (default 'value'; with 'label', copy and CSV use the label and a pasted label becomes the value; 1.1.0) / search / allowFreeText / loadOptions / fillRow (since 1.7.0; see "Searchable select editor (search / loadOptions / fillRow)") / multiple (true lets you choose any number of candidates; the value is string[]; since 1.11.0; see "Multiple selection (multiple)") | Pass-through (option.value is a string; combine with parseClipboardValue to convert types). With clipboard: 'label', if the pasted text is a candidate's label (compared with surrounding whitespace removed) its value, if it is a value as is, otherwise the raw string (labels are checked first; text equal to the current value's label keeps the current value = since 1.7.0; a candidate chosen in the editor writes its value without conversion) |
'date' | The native <input type="date"> (with picker: 'calendar' the cell becomes a text input with a calendar below; since 1.11.0; see "Time, date-time and calendar date editors (time / datetime / picker: 'calendar')"). The draft is 'YYYY-MM-DD' | ''. The input isn't made narrower than its content (year / month / day), and on narrow columns it opens past the cell. When you select a cell and start typing a character, it opens as a text input so the character isn't lost, and reads it as a date on commit (2026/3/15, 2026-03-15 and so on; the default parser's rules plus full-width digits and symbols and the 「2026年3月15日」 form; paste doesn't read these). If it can't be read, "日付で入力してください" (enter a date) shows and editing continues (canceled when focus leaves; 1.0.2) | strict (true marks values that can't be read as dates; 1.2.0; see "Validation (validate / validationMode)") / picker: 'native' | 'calendar' (default 'native'; 1.11.0) | ''→null / readable → normalized to 'YYYY-MM-DD' (numeric dates are year / month / day, or month / day / year with the year last = "4/11/2026" is April 11; not read as day / month / year) / unreadable → the raw string (digit-only strings = Excel date serial values "45678" or "5", strings whose year isn't 4 digits, strings without a year ("11/2", "Nov 1") and impossible dates ("2026/2/30") can't be read either; no rolling over into the next month) |
'time' | A text input (since 1.11.0). The value is 'HH:mm' (24-hour, no seconds). Reads 930, 9:30, 9 (9:00), 9時30分, 午後3時, 3pm and full-width digits. ↑ / ↓ move by step minutes (snapping to step; ↑ is later). picker: 'list' shows a list of times every step minutes below (with the list, ↓ goes down the list = later). See "Time, date-time and calendar date editors (time / datetime / picker: 'calendar')" | step (default 15 minutes) / picker: 'list' / strict (true marks values that can't be read as times) | '', whitespace only → null / readable as a time → 'HH:mm' (9:30, 09:30:00 (seconds only 0), 9:30 PM, 9時30分, full-width) / unreadable → the raw string (digit-only "930" isn't read on paste) |
'datetime' | A text input with a calendar below (since 1.11.0). The value is 'YYYY-MM-DDTHH:mm' (no time zone, no seconds), and the text in cells, copy and CSV is 'YYYY-MM-DD HH:mm' (without valueFormatter). Typing only a date gives defaultTime, and typing only a time gives that time on the cell's date (today if empty). timeInput: true adds a time input below the calendar. See "Time, date-time and calendar date editors (time / datetime / picker: 'calendar')" | defaultTime (default '00:00') / timeInput / step (↑ / ↓ in the time input; default 15 minutes) / strict | '', whitespace only → null / readable as a date-time → 'YYYY-MM-DDTHH:mm' (date and time joined by T or a space; a date only gets defaultTime) / unreadable → the raw string (values with a time zone, "…Z" or "…+09:00", aren't read either) |
'checkbox' | Toggles directly (no edit session). Pressing the checkbox itself, or Space on the active cell, toggles at once (pressing outside the checkbox in the cell only makes it the active cell; a double click doesn't toggle either). Enter / F2 / double click don't open an editor | checkedValue (default true) / uncheckedValue (default false). Checked is decided only by Object.is(value, checkedValue) | ''→unchecked / the string forms of checked / unchecked → the matching value / 'true', '1'→checked / anything else → unchecked |
'custom' | Draws the return value of render(ctx) in the edit overlay. Focus management and key bindings are your job (pressing another cell, a row number, a column header, the header corner, a row grip, an expand toggle or empty table space in the grid while it is open makes the grid end the edit and close the editor; pressing a part of the edited cell not covered by the editor doesn't close it. To keep the typed value, call ctx.commit(value) in the input's onBlur. Even if you call it after waiting for a server check, it is written to the edited cell after closing (not when the same cell has been opened and is being edited again before that, or after the grid is removed; values rejected by validation aren't written and { status: 'rejected' } is returned). If you don't call it, what was typed isn't written. Up to 1.4.0 the editor stayed open and grid keys didn't work until you double-clicked another cell) | render: (ctx: CellEditorContext<T>) => ReactNode, imeDirectInput?: boolean (when the grid's imeDirectInput is on, opens with the text confirmed with the IME in ctx.initialText; default false; since 1.2.0) | Pass-through |
Notes:
- The default parser applies to editor commit / paste / Delete clearing alike (e.g. a number column becomes
nullwhen cleared with Delete). An explicitparseClipboardValuealways wins. - number's
min/max/integer(truefor integers only) are used for value checks too (even withoutvalidate, cells out of range or with decimals get a mark / are not written with'reject').stepis only the step of the ↑↓ keys and spinner and isn't used for checks. Details in "Built-in number checks" under "Validation (validate / validationMode)". - For columns whose values contain line breaks, use
editor: { type: 'text', multiline: true }. The single-line input (default) has its line breaks removed by the browser, so opening and committing a value with line breaks loses them (committing without changing the value writes nothing, so just opening and closing doesn't lose them). Display follows the line breaks inautoHeightcolumns, and other columns show them on one line. - select columns whose value and label differ:
clipboard: 'label'(since 1.1.0): pasting a label ("交通費" (travel expenses)) from Excel puts in the value ('transport'), and copy and CSV output the label. Show the label in cells withvalueFormatteras before. See "Columns whose value and label differ". - select's blur is cancel (the value doesn't change). It is asymmetric with text / number / date, where blur = commit, but select has no draft concept since "choosing = committing at once". Only
allowFreeText: truecolumns commit the typed text (the same as the text editor; canceled if nothing was typed). - date's Tab follows the grid flow (commit + move). Move between segments in the picker with the ← → arrows.
- A double click on a checkbox counts as two clicks (toggling back and forth) (the same as Excel / AG Grid). When
renderCellis set it takes priority and the built-in checkbox cell isn't drawn. - custom's
ctx.commit(value)passesvaluethrough the column parser (parseClipboardValue?? the editor default) if it is a string, and if it isn't a string, skips parsing and writes the domain value as is.ctxhasrow/rowIndex(view row) /sourceRowIndex,rowKey(source based) /colIndex/column/value(the raw value when editing started) /initialText(the key when you started typing with a character key, or the text confirmed with the IME if the editor definition hasimeDirectInput: true; otherwise = when opened with a double click /Enter/F2/startEditing(),String(value ?? ''). To tell whether typing started it (to open a search box empty and so on), checkctx.initialText !== String(ctx.value ?? '')) /align/commit/cancel. The return value ofcommit(EditorCommitResult) gives the validation result for reject columns (safe to ignore). The second argument ofcommit(value, direction)('down' | 'up' | 'right' | 'left') sets where the active cell moves after committing (no move when omitted; theeditorEnterMoveprop doesn't apply to custom editors, so pass'down'explicitly to move down on Enter).ctx.commit/ctx.cancelof an earlier edit called after the edit ended (after commit / cancel / another cell's edit started) do nothing (ctx.commitreturns{ status: 'noop' }). Even editors that commit after an asynchronous check never write a late value into another cell. While the same edit continues, therender(ctx)component isn't re-created (since 1.3.0; including when a row is added to the group above while editing a group's first row and the edited position briefly points at a group row; up to 1.2.x it was re-created and what you typed was lost). - custom's frame: the return value of
render(ctx)is drawn in a frame at the same position and size as the cell being edited (.ssg-cell-editor,position: absolute). The frame is transparent, so give the root of the returned elementwidth: 100%; height: 100%; box-sizing: border-boxand a background color (var(--ssg-cell-bg)and so on) (without them it is only as tall as its content and the text of the cell below shows through). For design system input components, pass the height to the inner input too, not only the outer element (for Mantine,styles={{ wrapper: { height: '100%' }, input: { height: '100%', minHeight: 0 } }}). Components slightly larger than the frame (a star picker and the like) may draw past it, but the frame is inside the scroll area, so they are clipped at the area's edges and hidden under the total row (totalRow) pinned at the bottom. Components that extend outside the table, like candidate lists, should be drawn withcreatePortal(…, document.body)+position: fixed(positioned from the cell'sgetBoundingClientRect()). CallingpreventDefault()in the portal component'sonMouseDown(onPointerDown) keeps the input's blur (commit) from happening on press. Portal components don't follow when the table scrolls, so close them when the table (the element containing the editor) or the document scrolls (in auseEffect,window.addEventListener('scroll', onScroll, true), and inonScrollclose only whenevent.target === document || (event.target instanceof Node && event.target.contains(the editor's root element)). Listening in capture also delivers scrolling of the candidate list itself; it doesn't close on that. The same goes for design system components such as Mantine'sSelect). WhenstartEditing()is called on a cell that isn't visible (editing right after adding a row and so on), the grid scrolls to the cell right after showing the editor, so to avoid closing on that scroll, start watching and measuring 2 frames after opening (requestAnimationFrametwice) (or show it first withscrollToCell). The frame's content receives clicks (up to 0.61.0 it didn't, and they hit the cell below).
Per-row editors (editorForRow)
A column's editorForRow changes the editor per row within the same column (since 1.11.0). It is for tables where the value type differs by kind of item (a list of settings where the "quantity" row is a number, the "status" row a select and the "enabled" row a checkbox).
const EDITORS: Record<Setting['kind'], GridColumnEditor<Setting> | undefined> = {
qty: { type: 'number', min: 0 },
status: { type: 'select', options: STATUS_OPTIONS },
enabled: { type: 'checkbox' },
note: undefined, // the column's editor (text here)
};
const columns: GridColumn<Setting>[] = [
{ key: 'name', title: 'Item', width: 160 },
{ key: 'value', title: 'Value', width: 160, editable: true, editor: { type: 'text' }, editorForRow: (row) => EDITORS[row.kind] },
];- The returned editor beats
editor. Rows that returnundefineduse the column'seditor(text if none). - What the row's editor decides: the editor that opens, the default parser (commit, paste,
Delete), number's built-in checks (min/max/integer), date / numberstrict, checkbox cell drawing andSpace, whether typing can start withimeDirectInput, select'sclipboard: 'label', the fill handle default (copy if the last row of the source range is select), find targets (checkbox rows are excluded) and whetherCtrl+;(excelShortcuts) can write. On the entry row (newRow) it is decided by the draft row. - Places without a row use the column's
editor: column filterfilterType: 'auto'inference, the select names in condition summaries,/aiconditions, the columnfocusNewRow()enters first. To decide the column filter kind, writefilterType. - The function is called many times during rendering. Keep it pure and light (just look up a table by the row's value; returning a new object every time works, but returning a constant table is faster).
- If the row changes from outside during an edit and the editor kind changes (a number row becomes a checkbox row and so on), the edit is canceled (so committing with a different kind of editor than the one opened doesn't change the value).
- In your own code that branches on the column's
editor(insiderenderCelland so on), to also see per-row editors writecolumn.editorForRow?.(row) ?? column.editor(the type ofeditoris the same as 1.10 and doesn't include the function).
Searchable select editor (search / loadOptions / fillRow)
With the select editor's search: true, typed text filters the candidates (since 1.7.0). It is for columns with more than a few dozen candidates (customers, part numbers, staff). Columns without search work as before.
const customers: GridSelectEditorOption[] = [
{ value: 'C-001', label: 'Tokyo Trading', description: 'C-001', searchText: 'tokyo shoji' },
// ...
];
const columns: GridColumn<Order>[] = [
{
key: 'customer',
title: 'Customer',
width: 180,
editable: true,
editor: { type: 'select', options: customers, search: true },
valueFormatter: ({ value }) => customerName(value),
},
{
key: 'productCode',
title: 'Part no.',
width: 120,
editable: true,
editor: {
type: 'select',
options: products, // { value: part no., label: part no., description: product name, data: product }
search: true,
// write the product name and unit price from the chosen product in the same single edit
fillRow: (option) => {
const product = option.data as Product;
return { productName: product.name, unitPrice: product.price };
},
},
},
{ key: 'productName', title: 'Product', width: 200, readOnly: true },
{ key: 'unitPrice', title: 'Unit price', width: 100, readOnly: true },
];| Option | Type | Default | Description |
|---|---|---|---|
search | boolean | false (true with loadOptions or allowFreeText: true) | Filters candidates by typed text. The cell itself becomes an input with the candidate list below. |
allowFreeText | boolean | false | Text that isn't among the candidates can go in as is. While typing there is no highlight (↓ enters the candidates), and on Enter / Tab and when focus leaves, the typed text is written through the column's parser (parseClipboardValue ?? the default pass-through). If the typed text is the same as a candidate's label (differences of full-width / half-width, upper / lower case, hiragana / katakana and spaces count as the same), it is the same as choosing that candidate. |
loadOptions | (params: GridSelectLoadOptionsParams<T>) => Promise<readonly GridSelectEditorOption[]> | — | Gets candidates from a server. Called once on open (with the typed text when opened by a printable key, query: '' for a double click / Enter / F2), and about 200ms after each keystroke. params is { query, row, rowKey, column, signal }. Before calling with new text and when the editor closes, the previous signal is aborted and stale responses are discarded (nothing is cached). Filtering and order stay as the returned array (the grid only bolds the matching part). |
fillRow | (option: GridSelectEditorOption, context: { row: T; rowKey: GridRowKey }) => Partial<T> | — | Writes other fields too when a candidate is chosen. The returned fields are layered onto the row as is (not through the column's setValue) in the same single edit as the chosen value (one onRowsChange, one updateRows in serverSide, one undo). |
- How it searches: shows candidates whose label /
description/searchText/ value contains the typed text. Full-width and half-width (NFKC), upper and lower case, hiragana and katakana, and spaces aren't distinguished (「ボルト」「ぼると」「ボルト」 are the same; 「大阪 商事」 also matches 「大阪商事」). The long vowel mark 「ー」 and the hyphen / dash / minus family (‐–—−and so on) count as-too (「BLTーS」 typed with the IME on still matches the part number 「BLT-S」). To search by reading (「とうきょう」) or aliases, put them insearchText. - Order: candidates where any field equals the typed text come first ("A-100" typed puts it above "A-1000", which comes earlier in
options), candidates matching at the start next, and candidates matching in the middle after that (each group inoptionsorder). Matching parts of the label anddescriptionare bold (<mark>). - How it opens: with a double click /
Enter/F2, the input opens with the current value's name fully selected, the list shows everything and the current value is highlighted (typing replaces it; when the current value isn't in the list = not inloadOptions' first result and so on, nothing is highlighted and↓enters the candidates). PressingEnter/Tabwithout typing keeps the current value (only the commit's move, without writing). Printable keys and text confirmed with the IME (imeDirectInput) open with the list filtered by that text. - Keys:
↑/↓/PageUp/PageDownmove the highlight,Enter(commit and move down, followingeditorEnterMove) /Tab,Shift+Tab(commit and move right / left) commit the highlighted candidate, andEscapecancels. In candidate-only columns, typing highlights the first filtered result, andEnter/Tabwith 0 matches do nothing (it stays open; cancel withEscape). During IME conversion it doesn't filter; it filters on confirm (Enter/Escapeduring conversion are IME operations).Home/Endmove the input's caret. - Pointer: pressing a candidate commits it. The candidate the pointer moves over gets highlighted (even if the opened list sits under a still mouse, the highlight doesn't change until the pointer moves =
F2→Enterkeeps the current value; the plain select works the same since 1.7.0). Candidates whose name or extra text is cut off show the full text intitleon hover. - When focus leaves: candidate-only columns cancel (the same as the plain select), and
allowFreeTextcolumns commit the typed text (the typed text, not a candidate highlighted with↓; choosing a candidate isEnter/Tab/ a press). allowFreeTextcolumns: when no candidate matches the typed text, the list doesn't show (Enter/Tabwrite the typed text). Clearing all the text removes the highlight, andEnter/Tabwrite empty.- List: only what is visible is drawn (even with thousands of candidates, only a dozen or so elements are drawn). Rows are 28px high (44px on touch-first devices), showing up to 8 and scrolling inside. In
loadOptionscolumns, while loading it shows "候補を取得中…" (loading candidates…; while retyping, the previous list shows faded and the highlight is removed), on failure "候補の取得に失敗しました" (couldn't load candidates) and "再試行" (retry) (hovering showsError.messageintitle; after typing in a candidate-only column,Enteralso refetches the same text), and with no matches "一致する候補がありません" (no matching candidates) (text fromlocaleText'sselectSearchLoading/selectSearchFailed/selectSearchNoMatch). While refetching after retyping,↑/↓and the pointer don't move the highlight (pressing to choose still works). In candidate-only columns, pressingEnter/Tabwhile loading commits the first item of the list that arrives (the pending request for the text is sent at once; so fast input that types a part number and pressesEnterright away doesn't commit a candidate from the previous list). Text typed while waiting for that commit becomes what you started typing in the cell it moved to (so fast continued typing doesn't drop characters;Enter/Tab/↑/↓aren't carried over, andEscapecancels). When the edited cell scrolls out of the visible area (below the column headers, above the total row, within the table's frame), the list hides, and it shows again when the cell comes back. - Candidate arrays: build candidates outside the column definitions and reuse them (per-row functions should return the same candidate objects too). The text used for searching is cached per candidate object, so creating new candidates with
items.map(...)on every render rebuilds everything on every open (0.2–0.3 seconds each time for 50,000; the preparation on first open takes about the same). In development with React's StrictMode,loadOptionsis called twice on open (the first already aborted viasignal). - Cell display: cells show the column's
valueFormattertext (or the value itself if none), and the grid doesn't show the candidate label automatically (the same as the plain select; if the value is a code, usevalueFormatterto show a display name). The text when the editor opens is the label of the current value's candidate if it is inoptions, otherwise thevalueFormattertext.optionsis still required inloadOptionscolumns (putting some candidates in it serves the text on open,clipboard: 'label'paste and copy, and column filter names;[]if unused). - Writing
fillRow: return field names and values of the row ({ productName, unitPrice }). This column's own field being edited is ignored, since the chosen value wins. Fields of read-only columns (readOnly/editable: false/canEditCell) are written too (for tables that look up the product name and unit price from the part number). Values failing validation in fields ofvalidationMode: 'reject'columns aren't written (only that field is skipped, as with paste). Fields not in the columns can be written too. Fields whose value equals the current row aren't written (not included in write-backchangesor save marks either). Fields not in the columns can be written too (they go into serverSide'supdateRowsandonServerSideWriteError'schangeswithcolumnKey= the field name). It isn't called for commits that don't change the value (choosing the same candidate again), commits of typed text that differs from candidate names (allowFreeText; text equal to a name counts as choosing that candidate and calls it), paste, the fill handle orDelete(to keep other fields aligned on paste too, write them together in the column'ssetValue, or in serverSide look them up again from the rowsupdateRowsreturns).fillRowalso works on select columns without search. - Screen readers: the input is
role="combobox"+aria-autocomplete="list", the listrole="listbox", and candidatesrole="option"(aria-setsize/aria-posinsetgive the total and position). The highlighted candidate is pointed at witharia-activedescendant. With 0 candidates, while loading and on failure, the list doesn't show (aria-expanded="false"), and the notice row isrole="status"(role="alert"for failures). - Paste / copy: the same as the plain select (values as is; with
clipboard: 'label', mapped through the labels inoptions. Candidates with the same name = differing only indescriptioncan't be told apart on paste, so a pasted name equal to the current value's name keeps the current value, and otherwise it is the first candidate with that name. Making labels unique is the reliable way). - Fill handle: dragging a select column up or down copies the source value by default (since 1.7.0; advancing the trailing digits of a value would give another candidate or a code not among the candidates). Hold
Ctrl/⌘while dragging, or use the button after filling, to make a series. - Relation to other features: the column filter candidates' search box, the find bar (
find) and group rows (groupLabel: 'formatted') follow the rules of the values-and-labels guide. The column filter search box searches labels only (it doesn't look atsearchTextor kana variations). If you group rows by a column whose values are codes, addgroupLabel: 'formatted'so group rows show names. - Next.js:
loadOptions/fillRoware functions, so build column definitions in a client component (pass candidate arrays built on the server as props and put them in the column definitions withuseMemo). ForloadOptions, calling a Route Handler withfetch(url, { signal })works well (Server Actions are processed one at a time and don't stop onsignal, so fast typing delays results). /lite: the feature part isselectSearchFeature(createSpreadsheetGrid({ features: { selectSearch: selectSearchFeature } })). In setups without it, columns withsearch/loadOptions/allowFreeTextopen as the plain select editor (choose from the list only), with one development warning.fillRowis in the core, so it works without the feature.
Time, date-time and calendar date editors (time / datetime / picker: 'calendar')
Editors for times (editor: { type: 'time' }) and date-times ({ type: 'datetime' }), and a calendar for dates ({ type: 'date', picker: 'calendar' }) (since 1.11.0). In all of them the cell itself becomes a text input and the typed text is read. date's default (no picker = 'native') is the browser's <input type="date"> as before.
const columns: GridColumn<Shift>[] = [
{ key: 'day', title: 'Date', width: 120, editable: true, editor: { type: 'date', picker: 'calendar' } },
{ key: 'start', title: 'Start', width: 90, editable: true, editor: { type: 'time' } },
{ key: 'slot', title: 'Slot', width: 90, editable: true, editor: { type: 'time', picker: 'list', step: 30 } },
{ key: 'checkedAt', title: 'Checked', width: 160, editable: true, editor: { type: 'datetime', defaultTime: '09:00', timeInput: true } },
];| Option | For | Default | Description |
|---|---|---|---|
picker | date | 'native' | 'calendar' makes the cell a text input with a calendar below (pressing the month name gives a list of months, and again a list of years). |
picker | time | no list | 'list' shows a list of times every step minutes below the input (the current value is highlighted; empty cells show the area near the current time). With the list, ↓ / ↑ follow the list's direction (↓ = down the list = later). |
step | time / datetime | 15 | Minutes moved by ↑ / ↓ (1–720). The interval of time's picker: 'list' list. For datetime, ↑ / ↓ in the time input (timeInput). |
defaultTime | datetime | '00:00' | The time ('HH:mm') when only a date is typed, or a day is pressed in the calendar for a cell without a time. Also used for pasted date-only text and the text of cells whose value is date-only. |
timeInput | datetime | false | true adds a time input below the calendar (a typable field; Enter / Tab / Escape / ↑ / ↓ work the same as in the cell's input). |
strict | date / time / datetime | false | true marks values that can't be read (see "Validation (validate / validationMode)"). |
- How typed text is read (the editor's input; broader than paste): times read
930(9:30),9(9:00),1745,9:30,9.30,9時30分,9時半,午後3時,3pmand full-width digits. Dates read2026/12/5,2026-12-05,2026年12月5日,20261205,12/5,1205(this year if there is no year). Date-times join a date and a time with a space orT(12/5 9:30,2026年12月5日 9時). A date only getsdefaultTime, and a time only (13:15,9時,3pm) gives that time on the cell's current date (today if empty) (in date-time columns, digits-only930is a date = September 30; when typing only a time, include a time marker). While you type, the calendar moves to the month of the date it could read and marks that day as selected. - Paste / default parser: as in the default parser column of the table in "Cell editors (editor)" (digit-only "930" and "1205" aren't read as times / dates, so quantities and codes don't become times by mistake). The same in setups without the editor parts (in
/litewithout the feature). - Keys:
Entercommits and moves in theeditorEnterMovedirection,Tab/Shift+Tabcommit and move right / left,Escapecancels, andCtrl/⌘+Enterfills the selection (excelShortcuts).↑is later and↓earlier (date by 1 day, time bystepminutes; datetime's cell input by 1 day and its time input bystepminutes; empty cells start from today / now).PageUp/PageDowndon't scroll the table. There is no arrow-key movement inside the calendar (moving the day with↑/↓moves the calendar's mark along; to jump by weeks or months, type a date). PressingEnter/Tabwithout typing keeps the current value (nothing is written). - Text that can't be read: trying to commit with
Enter/Tabshows "時刻で入力してください(例: 9:30)" (enter a time, e.g. 9:30) or similar at the top of the calendar / time list (for time without a list, in a bubble below the editor) and keeps editing (text fromlocaleText'senterDate/enterTime/enterDateTime). When focus leaves, it is canceled. Clearing everything and committing gives empty (null). - Calendar: pressing a day commits that day for date, and for datetime changes only the date and keeps editing (the time stays; cells without a time get
defaultTime). "今日" (today) does the same with today, and "クリア" (clear) commits empty. The calendar part is loaded when it opens (not in the initial JS;preloadGridPopups()loads it ahead too). The time list commits the pressed time. - Touch-first devices (
pointer: coarse): opened with a double tap /F2/Enter, it opens the browser's input (date / time / datetime-local) (easier to choose with than the on-screen keyboard). When you start typing text, the text input. - Popups: drawn outside the table like the select list (following
popupContainer;classNames.popoveris added). When the cell scrolls out of the visible area they hide, and they show again when it comes back. - Screen readers: the input is
role="combobox"(the calendar hasaria-haspopup="dialog", and the time list is alistboxwith the highlighted time inaria-activedescendant). The calendar isrole="dialog"named "(column name) のカレンダー" (calendar), the time list is named "(column name) の時刻" (times), and the time input is named "時刻" (time) (localeText'sdateEditorCalendar/timeEditorList/dateTimeEditorTime). Day buttons in the calendar are namedYYYY-MM-DD. - Column filters: datetime columns with
filterType: 'auto'get a list of date values (dateSet, per day). time columns are decided from the values (a list of values in clientSide). - Global filter: datetime columns (without
valueFormatter) match on either the value (2026-12-05T09:30) or the on-screen text (2026-12-05 09:30) (regardless ofglobalFilterMatch). Ctrl+;(excelShortcuts): writes today's date into date and datetime columns (datetime withdefaultTime). Doesn't write into time columns./lite: the feature part isdateTimeEditorsFeature(createSpreadsheetGrid({ features: { dateTimeEditors: dateTimeEditorsFeature } })). In setups without it, time / datetime open as a text input (the default parser reads the committed text), and date withpicker: 'calendar'opens as the browser's date input, with one development warning. Value shapes, cell text, paste andstrictare in the core, so they are the same without the feature.
Multiple selection (multiple)
With the select editor's multiple: true, any number of candidates can be chosen in one cell (since 1.11.0). It is for columns like owners, tags and skills.
const SKILLS = [
{ value: 'ts', label: 'TypeScript' },
{ value: 'go', label: 'Go' },
{ value: 'rs', label: 'Rust' },
];
const columns: GridColumn<Member>[] = [
{ key: 'skills', title: 'Skills', width: 220, editable: true, filterType: 'set', editor: { type: 'select', multiple: true, options: SKILLS } },
// columns with many candidates: filter by typing (search) / load from a server (loadOptions)
{ key: 'owners', title: 'Owners', width: 200, editable: true, editor: { type: 'select', multiple: true, search: true, options: STAFF } },
];- Value: an array of candidate
values (string[]). When nothing is chosen,[]is written (null/undefinedare treated the same as[]). The order follows the candidates' order (values not among the candidates stay at the end in their original order; duplicates are one). Values are compared by content (order differences count as the same), so commits that change nothing aren't written, and change tracking (trackChanges) and change highlighting (highlightChanges) treat the same content as unchanged too. Don't re-create the candidate array (options) on every render (put it outside the component or inuseMemo; the name table is remembered per array). - Cell: names of the chosen candidates are lined up as chips (
.ssg-multi-select-chipinside.ssg-multi-select-chips; colors--ssg-multi-select-chip-bg/--ssg-multi-select-chip-text). Chips that don't fit the column width are cut off, and hovering shows all names in a tooltip. Columns withvalueFormattershow that text instead of chips. Values not among the candidates become chips of the value itself. - Editor: the chosen chips in the cell (removable with
×), the candidate list with checks below, and a description of the keys (localeText'smultiSelectHint).↑/↓/PageUp/PageDownmove the highlight,Spacetoggles the highlighted candidate's check,Entercommits and moves in theeditorEnterMovedirection,Tab/Shift+Tabcommit and move right / left,Escapecancels, andCtrl/⌘+Enterfills the selection (excelShortcuts). Pressing a candidate only toggles its check and doesn't commit.Backspacewith no typed text unchecks the last value. When focus leaves, it commits (to keep what you were choosing; single-choice select cancels as before). Committing without changes writes nothing. - Filtering by typing (
search: true; withloadOptionsit searches even if omitted): an input sits after the chips, and the typed text filters the list (the same search rules as the searchable select editor). The typed text doesn't become a value (it only filters).Enterwith typed text adds the highlighted candidate and clears the typed text (it doesn't close; when no candidate matches or while loading, it commits; you can narrow to one and add it withEnter; the key description ismultiSelectSearchHint).Enterwith no typed text commits.Spaceright after typing is a character (a space), andSpaceafter moving the highlight with↑/↓toggles the check (typing again makes it a character again).Home/Endmove the input's caret. In columns without search,Home/Endgo to the first / last of the list, and printable keys type ahead by name prefix (Spaceand arrow keys forget the typed text; text confirmed with the IME isn't taken, so for candidates with Japanese namessearch: trueis recommended). When you start typing text, columns with search open filtered by that text, and columns without it open with the candidate found by that text highlighted. loadOptions: the same as the searchable select editor (called once on open, then about 200ms after each keystroke; aborted withsignal; failures show "候補の取得に失敗しました" (couldn't load candidates) and "再試行" (retry); textmultiSelectLoading/multiSelectFailed/multiSelectNoMatch).optionsis used to look up the names of the current values (names of fetched candidates are remembered and used for the editor's chips; cell chips, copy, find and sorting use the names inoptions, and values not inoptionsshow the value text. To show names in cells, put the candidates for the values you use inoptionstoo).- Sorting: compares the text of names joined in candidate order (the same even if the values' order differs from the candidates;
[]with nothing chosen is empty = last). - Copy / CSV / export: the values joined with 「、」 (「, 」 with the English table
localeTextEn;localeText'smultiSelectSeparator) (columns withclipboard: 'label'join the names). - Paste / default parser: splits on the separators (
multiSelectSeparatorand 「、」「,」「,」), trims surrounding spaces, and matches each against candidate values or names (values first;clipboard: 'label'columns look at names first; text that doesn't match goes in as a value as is). For candidates whose name or value contains a separator character (「A、B 両方」), if the following pieces joined with the original separator match that candidate, it becomes that candidate (longest first). Empty text is[]. The same in setups without the editor parts. - Column filters: the value list (
filterType: 'set') lists candidates one by one (in candidate order, "(空白)" (blank) last) and keeps rows that contain any of the chosen values ("(空白)" is rows with[]/null). Exclude (mode: 'exclude') follows the same idea and keeps rows containing any value that isn't unchecked (removing rows that have only unchecked values). Theselectcondition keeps rows containing that value. Text conditions (contains / equals / starts with / ends with / blank) compare against each value's name and value, and keep the row if any matches ("contains TypeScript" is rows with TypeScript chosen; blank is rows with nothing chosen).filterType: 'auto'gives the value list (the condition field compares the same way). Columns whose candidates are decided only byeditorForRow(the column'seditorisn't multiple selection) list values instead of candidate names in the value list (because candidates can't be looked up; to show names, put the candidates in the column'seditortoo). - Find and global filter: find in cells matches the cell's names (the on-screen text). The global filter matches both names and values. Neither matches across the boundary between values.
- Not available (in this version):
allowFreeText(entering text not among the candidates),fillRow, a limit on how many can be chosen, and grouping rows per value.allowFreeText/fillRowhave no effect if written, androwGroupgroups by each combination of chosen values (not per value; the group name is the candidate names joined, and[]is "(空白)" (blank)). Each warns once in development. getExportData: the cell'svaluestays an array, andtextis joined with the separator.- Screen readers: in columns without search the editor box, and in columns with search the input inside, is
role="combobox". The list isrole="listbox"+aria-multiselectable="true", the candidates'aria-selectedis the check, and the highlight isaria-activedescendant. The chip×is named with the candidate's name. /lite: the feature part ismultiSelectFeature(createSpreadsheetGrid({ features: { multiSelect: multiSelectFeature } })). In setups without it, the editor is a text input (it opens with the current values joined with ",", and the default parser reads the committed text), and cells show the names joined as text, with one development warning. Value shapes, copy, paste, filters and sorting are in the core, so they are the same without the feature. Filtering by typing (search/loadOptions) is also in this part, soselectSearchFeatureisn't needed.
Validation (validate / validationMode)
column.validate validates cell values. It returns true (valid) / false (invalid, default message) / a string or { message } (invalid + message).
Built-in number checks: the number editor's min / max / integer: true also check values (they work without writing validate).
{ key: 'qty', title: 'Qty', width: 120, editable: true,
editor: { type: 'number', min: 0, integer: true } } // an integer of 0 or more- The checks run in the order "is it a number → is it an integer → is it in range", and the first that fails gives the message ("数値で入力してください" (enter a number), "整数で入力してください" (enter an integer), "0 以上で入力してください" (enter 0 or more), "100 以下で入力してください" (enter 100 or less), "1〜5 で入力してください" (enter 1 to 5)).
- What counts as a number is numbers and strings the column's default parser reads as numbers (initial data such as
'12'/'1,234'/'12'). Empty (null/undefined/ whitespace-only strings) passes (to make it required, usevalidate). - When combined with
validate,validatecomes first. Avalidatefailure keeps its message (not overwritten by the built-in message), and only valuesvalidatepasses go through the built-in checks (one message per cell; the valuevalidatereceives and its behavior are as before). validationMode(mark / reject),showValidationMarksandgetInvalidCells()work the same way for the built-in checks.- To change the message, write the same condition in
validateand return your own message (validatecomes first, so yours shows).
Checks for numbers and dates that can't be read (strict): strict: true on the number and date editors marks values that can't be read as numbers / dates ("¥12,000", "2026年11月4日" and so on) (not written with 'reject'; since 1.2.0. Without it, as up to 1.1, unreadable values go in as text without a mark).
{ key: 'due', title: 'Due', width: 140, editable: true, editor: { type: 'date', strict: true } } // "日付で入力してください" (enter a date)- number's
strictchecks only "is it a number" (message "数値で入力してください" (enter a number)). Withmin/max/integer, the same check happens without writingstrict. - What date's
strictcounts as a date is validDates and strings date's default parser reads ('2026-03-15'/'2026/3/15'and so on; what can't be read is in the default parser column of the table in "Cell editors (editor)"). The message islocaleText.enterDate("日付で入力してください(例: 2026/3/15)" (enter a date, e.g. 2026/3/15)). - Empty (
null/undefined/ whitespace-only strings) passes.validatecomes first, as with the number checks.
Modes (validationMode, default 'mark'):
'mark'(default) — writes the value and shows the cell as invalid (background + top-right marker) + a tooltip with the message (when hovering, and when the cell becomes the active cell by keyboard / tap; the cell also getsaria-invalidand the message asaria-description; 1.0.1). Invalid state is derived at display time (not kept in state), so it always matchesrows, even after paste, clear, initial data, undo/redo orrowsreplaced from outside.'reject'— refuses writes that fail validation. Behavior per path:- Editor commit (Enter / Tab): the commit is refused and editing continues. The editor frame turns red and an immediate error bubble shows the message. On blur (focus left), it falls back to cancel (closes the editor with the value unchanged).
- Paste: only the cells that fail are skipped (other cells are written; the same semantics as skipping readonly cells).
- Delete / Backspace clearing: skipped if the clear value fails validation (this lets you express "required columns can't be emptied with Delete").
setValueinrenderCell/ checkbox toggles: become no-ops.
Contract and notes:
- Keep
validatepure and light. For mark display it is evaluated on every render for every visible cell being drawn (only columns with validate) (the same cost class as thecellClassNamefunction). - The validation context is
{ value, row, column }(rowis the row before the write; view indexes aren't passed because they are unstable under sorting / filtering). - For a check of everything before saving, use the handle's
getInvalidCells()(see "Imperative API"). - The colors of the invalid display can be adjusted with the tokens
--ssg-invalid/--ssg-invalid-bg(light / dark supported). The text color of the error bubble is--ssg-invalid-contrast(default#ffffff). - When the same cell has a note (
cellNote), the error's 6px triangle sits on top of the note's 10px triangle (see "Cell notes (cellNote)").
Controlling when marks show (showValidationMarks)
column.validate is "the rule definition" and the grid prop showValidationMarks (default true) is "when to show the marks"; the two are independent. The default is always-on, real-time display as before. false shows no marks and also skips evaluating validate per visible cell (since the results are only used for showing marks).
- Declarative and stateless: turn the display on and off by switching the prop with React state (there is no imperative API like
showMarks()). Invalid state itself is derived at display time (not kept in state), so the moment marks show again they always match the currentrows(also after undo / replacement from outside). getInvalidCells()doesn't depend on the display and always scans everything (use it for pre-submit checks while marks are hidden).validationMode: 'reject'isn't affected. reject is a gate at write time (not a display feature), and the error bubble when an editor commit is refused shows even while marks are hidden. Design decision: the editor's error bubble is "immediate feedback on the action you just took", a different role from marks, which "show the invalid state of the whole data", so it isn't subject to the display control.
Recipe: validate everything on submit (marks show only on submit)
Show nothing while typing, validate everything on submit, show marks + a notice if anything fails, and clear the marks when a resubmit succeeds after fixing — a standard UX for business forms. The only state you hold is one boolean.
function OrderForm() {
const gridRef = useRef<SpreadsheetGridHandle<Row>>(null);
const [rows, setRows] = useState<Row[]>(initialRows);
const [showErrors, setShowErrors] = useState(false);
// rules stay defined on the columns (rules that refer across the row, like "fully empty rows aren't validated", can use ctx.row)
const columns: GridColumn<Row>[] = [
{ key: 'itemCode', title: 'Item code', width: 200, editable: true,
validate: ({ value, row }) =>
isEmptyRow(row) || String(value ?? '').trim() !== '' || 'Some rows have no item code' },
{ key: 'qty', title: 'Qty', width: 120, editable: true,
validate: ({ value, row }) =>
isEmptyRow(row) || /^[1-9]\d*$/.test(String(value ?? '').trim()) || 'Enter the quantity as an integer of 1 or more' },
];
const handleSubmit = () => {
const invalid = gridRef.current?.getInvalidCells() ?? [];
if (invalid.length > 0) {
setShowErrors(true); // only now do the marks show
// messages come per cell, so dedupe them into one notice
notifyError([...new Set(invalid.map((c) => c.message))].join(' / '));
// move to the first error cell. scrollToCell / selectCell take view positions (rows after sorting / filtering, and the
// column order counting columns the grid adds such as the row drag handle column), so look them up from rowKey and the column key.
// Passing sourceRowIndex or columns.findIndex as is goes wrong while sorted or when there are synthetic columns.
const grid = gridRef.current;
const first = invalid.find((cell) => (grid?.getViewRowIndex(cell.rowKey) ?? -1) >= 0); // skip rows hidden by filtering
if (grid && first) {
const viewRow = grid.getViewRowIndex(first.rowKey);
const col = grid.getColIndex(first.columnKey);
if (col >= 0) {
grid.scrollToCell(viewRow, col);
grid.selectCell(viewRow, col);
grid.focus(); // selectCell doesn't move focus
}
}
return;
}
setShowErrors(false); // clear the marks on success
submit(rows);
};
return (
<>
<SpreadsheetGrid
ref={gridRef}
columns={columns}
rows={rows}
onRowsChange={setRows}
showValidationMarks={showErrors}
/>
<button onClick={handleSubmit}>Submit</button>
</>
);
}Note: getInvalidCells() is clientSide only, so this recipe also assumes clientSide (rows supplied) (serverSide doesn't hold all rows, so it returns an empty array + console.warn).
Cell notes (cellNote)
The equivalent of FarPoint SPREAD's cell memos / Excel's notes. Cells for which column.cellNote returns a string get a mark at the top right, and hovering shows that string in a tooltip.
const columns: GridColumn<Part>[] = [
{
key: 'partNo',
title: 'Part no.',
width: 140,
// several notes joined with \n show on separate lines.
cellNote: ({ row }) =>
[row.isNew && 'This structure was added by this import.', row.otherUses > 0 && `Also used in ${row.otherUses} other places`]
.filter(Boolean)
.join('\n'),
},
{
key: 'price',
title: 'Sale price',
width: 110,
cellNote: ({ value }) => (value === 0 ? 'The sale price is registered as 0.' : undefined),
cellClassName: ({ value }) => (value === 0 ? 'bg-amber-50' : undefined), // background colors with cellClassName as before
},
];- Return value: a string means a note (
\nbreaks lines).undefined/null/ an empty string (only whitespace) means no note.ctxisCellStyleContext<T>, the same as the function form ofcellClassName(row/rowIndex/sourceRowIndex/rowKey/colIndex/value/column/isActive/isSelected/isEditing/readOnly). - Mark: a 10px triangle at the top right of the cell (default color light
#f59e0b/ dark#fbbf24). Change the color with the token--ssg-note-indicator. Cells with a note get the public contract class.ssg-body-cell--has-note(the mark is::before; to change its shape, override.ssg-body-cell.ssg-body-cell--has-note::before). - On a cell with an input error too: the error's 6px red triangle (
::after) sits on top of the note's triangle, so both show as a double triangle. The tooltip is "error message → line break → note". WhileshowValidationMarks={false}, only the note shows. - Tooltip: shown with the grid's existing custom tooltip (
data-ssg-tooltip; see "Tooltips"). It shows on hover (with the existing delay). The note also goes into the cell'saria-description, and assistive technology reads it as the active cell's description (1.0.1). On cells with a note, the note takes priority over the full-text tooltip for truncated text (showCellOverflowTooltip). - Not included in output: not output to CSV / TSV (copy) /
getExportData(display-only information). - When it is evaluated: only for rendered cells, every time the row re-renders (the same cost class as the
cellClassNamefunction; keep it pure and light). Rows re-render when the row data, column definitions and the like change, so when the note content comes from state other thanrows(a Map of import results and so on), put that state in theuseMemodependencies and re-createcolumns.
Conditional formatting (conditionalFormat)
A lightweight helper equivalent to Excel's "conditional formatting". One column option overlays a data bar (amount) / color scale (amount or direction from a reference) / status chips (state) on the default cell rendering. min / max are computed automatically from the shown rows (fixed values are fine too). The function form of cellClassName can make the same look, but this saves writing the min / max aggregation and bar drawing every time.
const columns: GridColumn<Row>[] = [
{ key: 'qty', title: 'Stock', width: 100, align: 'right', conditionalFormat: { dataBar: {} } },
{ key: 'delta', title: 'MoM %', width: 100, conditionalFormat: { colorScale: { type: 'diverging', min: -30, mid: 0, max: 30 } } },
{ key: 'price', title: 'Unit price', width: 100, conditionalFormat: { colorScale: {} } },
{ key: 'status', title: 'Status', width: 110, conditionalFormat: { chips: { Active: 'good', Paused: 'warning', Discontinued: { tone: 'critical', label: 'Discontinued (no longer sold)' } } } },
];- Data bar (
dataBar): shows the size of the value as a background bar (.ssg-cf-bar; 4px margins above and below, rounded right end). Whenmin/maxare omitted, it uses the minimum / maximum of the numbers in the view rows (after filtering / sorting; for SSRM the loaded range) and recomputes when edits / filters change them (no re-render if the content is the same). Columns with negative values extend left from a 0 axis (.ssg-cf-bar--negative; colornegativeColor/--ssg-cf-bar-negative), and columns with only negatives have the axis at the right end (the same as Excel).colorsets the bar color (default--ssg-cf-bar= a fixed light blue; it doesn't follow changes to--ssg-accent, so override--ssg-cf-bartoo to match), andshowValue: falseshows only the bar without text. Not shown on non-numeric cells. - Color scale (
colorScale): tints the cell background (.ssg-body-cell--cf-scale) by value. The text color doesn't change (limited to light steps to keep contrast).type: 'sequential'(default) goes from light → dark in one hue (--ssg-cf-seq-min→--ssg-cf-seq-max).'diverging'makesmid(when omitted, 0 ifmin < 0 < max, otherwise the middle) the neutral color (--ssg-cf-div-mid) and deepens the negative side (--ssg-cf-div-negative) / positive side (--ssg-cf-div-positive) in different hues. Passing an array of CSS colors tocolors([light, dark]/[negative, neutral, positive]) replaces them. Colors are interpolated with CSScolor-mix()(tokens and any CSS colors can be mixed as is). - Status chips (
chips): a map from value (String(value)) → tone, or a function returning a chip fromctx(the same as the function form ofcellClassName). A chip (.ssg-chip.ssg-chip--<tone>) is an icon + label pill and doesn't carry meaning by color alone (icon: falsefor no icon; on columns narrower than 80px it tightens the padding and drops the icon to favor the text = since 1.0.2). Whenlabelis omitted, the cell's displayed text (aftervalueFormatter; find-in-cells highlighting stays too; when you writelabel, find in cells searcheslabel), andcolorgives any color (.ssg-chip--custom). Values not in the map / values for which the function returnsnullstay as plain text. - Combining: one column can have both
dataBarandcolorScale(the bar sits on top of the background color). Explicit styles fromcellClassName/getRowClassNamewin over conditional formatting. - Scope: display only. Doesn't affect CSV / TSV / the clipboard /
getExportData/ sort / filter. OnrenderCellcolumns, data bars (dataBar) and color scales (colorScale) are drawn in the cell's background and the content is drawn byrenderCell(chipsanddataBar.showValue: falsehave no effect). Withmotion'on', the bar length and background color change smoothly as values change. - Color tokens:
--ssg-cf-bar/--ssg-cf-bar-negative/--ssg-cf-seq-min/--ssg-cf-seq-max/--ssg-cf-div-negative/--ssg-cf-div-mid/--ssg-cf-div-positive/--ssg-cf-<tone>/--ssg-cf-<tone>-bg(tone = neutral / info / good / warning / critical). The dark theme has separate values with re-chosen steps.
flex and autoSize (how column widths are decided)
There are two ways to "let the grid decide" column widths, and they are separate concepts that decide differently. You can choose per column and mix them. If unsure which to use, pick from the table below.
flex (column.flex) | autoSize (column menu / boundary double click) | |
|---|---|---|
| What it fits | The container's leftover width (doesn't look at content) | The length of cell content (doesn't look at the container) |
| Reactivity | Grows and shrinks reactively with container resizes | Computes a fixed px width once from the content at run time (doesn't follow afterwards) |
| How it starts | Set flex in the column definition (= declarative) | The column menu's "この列の幅を自動調整 / すべての列の幅を自動調整" (auto-fit this column / all columns), or double-clicking the header boundary (resize handle) for that column only (= an action) |
| Scope | Center (non-pinned) columns only | Any column |
| Typical use | Use the table's full width / let specific columns absorb the leftover space | Keep content from being cut off |
- flex — center columns with
flexshare "the available width (container width − row header − pinned total − total of fixed-widthcolumns)" by theflexratio, clamped byminWidth/maxWidth. Distributed widths are aligned to whole px (fractions are cut and carried to the next column, so each column is within 1px of its ratio width and the total never exceeds the available width; this prevents a 1px horizontal scrollbar from fractions). When fixed columns exceed the available width, flex columns collapse to their minimum width (minWidth, or an internal default of 50px when unset) and the excess becomes horizontal scrolling. Ignored on pinned columns. - autoSize — computes a fixed px width once to fit the cell content (it doesn't look at the container width). The width is settled by the content at that moment and doesn't follow later changes to the container or content. Besides the column menu, double-clicking the header boundary (resize handle) fits that column to its content (resizable columns only; like AG Grid's boundary double click).
Measurement has two phases. Phase 1 estimates all shown rows with canvas to narrow down the longest candidates per column, and Phase 2 measures only those candidates in real DOM with hidden cells under the grid root. So it looks at every row (including the longest values off screen) and reflects thevalueFormatterresult, letter-spacing and padding exactly as drawn, without overflow. Columns withsuppressAutoSize: trueare left out of the measurement and keep theirwidth.
Status chip (conditionalFormat.chips) columns are measured including the chip frame (padding and icon) andlabel(since 1.0.2).
For columns that draw their own DOM (badges and so on) in renderCell, text doesn't give the width, so setestimateCellWidth. Those columns skip the Phase 1/2 text measurement and are settled by the running max over all rows of the content width returned byestimateCellWidth(row)+ the cell frame (trusting what the consumer reports; no mounting).
Limit —autoHeight: truecolumns aren't covered by autoSize (skipped by the column menu / boundary double click / auto-fit all columns, keeping theirwidth). The intended behavior of autoHeight columns is "fix the width and wrap long text", but autoSize measures on a single line, so measuring an autoHeight column would make the long text you want wrapped a single line wide and the column extremely wide (there is no default limit on column width, so it grows as long as the text). Run long-text columns with autoHeight (wrapping) or a fixed width withmaxWidth(truncation).
Manually resizing a flex column turns it into a fixed px width at the dragged width (from then on that column isn't flex). The same goes when autoSize fits it to the content (column menu / boundary double click / "すべての列の幅を自動調整" (auto-fit all columns) / autoSizeColumns): it becomes a fixed px width at the fitted width and stops following the window width (for columns you want to keep flex, use suppressAutoSize: true). The fixed width lasts until that column's flex / pinned / width settings change (pin toggle / replacement by the parent) or the columns are reset, and then it goes back to flex. Toggling visibility / reordering, or passing the same columns content as a different reference, doesn't clear it.
autoSizeColumns (auto-fit when data arrives)
The grid prop autoSizeColumns?: 'onMount' | 'onDataChange' | false (default false) auto-fits all column widths to their content when data arrives. The fit uses the same engine as autoSize above (the column menu's "すべての列の幅を自動調整" (auto-fit all columns)); 'onMount' runs once when data first arrives, and 'onDataChange' every time rows (the reference) changes (= every time the data is replaced). For replacing the whole data each time, such as form submission results, and refitting every time, use 'onDataChange'.
- Relation to
GridColumn.suppressAutoSize: since it is the same engine, columns withsuppressAutoSize: true(andautoHeight: truecolumns) are left out of this auto-fit too and keep theirwidth. When "most columns should fit their content, but a few should show at a fixed width", give those columnssuppressAutoSize: true+width(a per-column opt-out). Columns withestimateCellWidthare estimated with the same rule as normal autoSize (the running max over all rows of the reported content width). - The trigger is only changes of
rows(data). Filtering / sorting, column reordering / visibility / pinning (=columnschanges) don't refit (to avoid widths jumping right after manual actions). So manually resized widths are overwritten at the next data arrival ('onDataChange') (take columns you don't want refit out withsuppressAutoSizeabove). - Fitted widths go into the internal column width state, and
onColumnsChangeisn't called. It doesn't conflict even if you holdcolumnsas controlled. - Disabled in serverSide (
dataSource) (rows not loaded can't be measured; clientSide only). - When measurement is heavy, the existing measuring overlay shows even in production (no noticeable difference with small data).
// Example: replace the whole form submission result, and refit column widths to the content each time.
// The consumer only passes autoSizeColumns (no tokens or effects needed).
<SpreadsheetGrid
rows={rows} // replaced with a new array reference on every submit
columns={columns}
autoSizeColumns="onDataChange"
/>auto-height rows (variable row height)
Makes row height vary with content (long text wraps and the row grows vertically). Turning it on needs both of two switches:
- The grid prop
autoHeight={true}(the main switch; defaultfalse). column.autoHeight: trueon at least one column. That column wraps (white-space: normal) and drives the row height.
Internally it is "grid autoHeight && column.autoHeight === true", and only cells where both are true vary (one alone has no effect). In rows with autoHeight: true on several columns, the tallest cell sets the row height.
- Row count gate: auto-height works only while there are 50,000 view rows or fewer. Above that it falls back to uniform row height (
rowHeight) automatically (because of prefix-sum cost and the browser's element height limit; a console warning in development). estimateRowHeight: the estimated row height used for unmeasured rows off screen in virtualization (defaultrowHeight). When a row comes on screen it is replaced with the measured value (it is not an upper limit).- Row height is measured (the height of the content of
autoHeightcolumn cells; the minimum is the baserowHeight), with no upper clamp. If content shrinks, for example by widening the column, the row shrinks too. - Line breaks:
autoHeightcolumns wrap following the value's line breaks (consecutive spaces collapse into one). For columns whose values with line breaks are edited, useeditor: { type: 'text', multiline: true }(see "Cell editors (editor)"). - Vertical alignment: every cell's box is the row's height. In grown rows,
autoHeightcolumns align their content to the top (the first line of the wrapped text) and other columns to the middle. The grid'sverticalAlign('top'/'center') changes all columns, and a column'sverticalAlignonly that column (the column wins). Single-line rows are all centered. When editing a top-aligned cell, the editor's text also appears on the cell's first line (including the single-line editor and text being converted by the IME; since 1.2.0. Before that only the multiline editor did, and the single-line editor appeared in the middle). autoHeightcolumns aren't covered by autoSize (since they assume wrapping; see the limit in "flex and autoSize" above).- For the quality of wrap positions (phrase-based wrapping of Japanese and so on), see the next section, "Wrapping Japanese text".
<SpreadsheetGrid
rows={rows}
columns={[
{ key: 'id', title: 'ID', width: 80 },
// ↓ this column wraps and drives the row height
{ key: 'note', title: 'Note', width: 320, autoHeight: true },
]}
autoHeight // ← the main switch (without it, the column-side autoHeight is ignored)
/>Wrapping Japanese text (word-break / BudouX)
autoHeight: true columns wrap their cells (variable row height), and at this point the browser's standard character wrapping with line-breaking rules applies (punctuation and closing brackets aren't placed at the start of a line, and so on). Beyond that, "quality" has two levels.
① CSS only (no library changes) — adjust with the column's wordBreak / lineBreak. In particular, wordBreak: 'auto-phrase' does phrase-based wrapping with BudouX (not splitting in the middle of words) in Chromium (Chrome / Edge). If you can assume Chromium, such as for internal apps, this alone gives phrase-based wrapping (no added dependency).
// Chromium (Chrome / Edge): phrase-based wrapping with CSS alone.
{ key: 'desc', title: 'Description', autoHeight: true, wordBreak: 'auto-phrase' }
auto-phraseisn't supported in Firefox, and Safari has it partly behind a flag (its own engine, not BudouX). For stricter line-breaking rules, combine it withlineBreak: 'strict'.
② Cross-browser (using BudouX on your side) — to get phrase-based wrapping in every browser, use BudouX (by Google, no dictionary, about 15KB, fully client-side; also the engine behind Chromium's auto-phrase) in your own renderCell. This library doesn't bundle BudouX (the seam policy; like getExportData(), dependencies stay on your side). The key is combining it with wordBreak: 'keep-all' so text wraps only at the break opportunities BudouX inserts (zero-width spaces).
import { loadDefaultJapaneseParser } from 'budoux';
const parser = loadDefaultJapaneseParser();
// column definition (your side)
{
key: 'desc',
title: 'Description',
autoHeight: true, // wrapping = variable row height
wordBreak: 'keep-all', // don't break between characters (wrap only at zero-width spaces)
renderCell: ({ value }) =>
parser.parse(String(value ?? '')).join(''), // ZWSP at phrase boundaries (memoizing per value is recommended)
}Virtualization draws only visible cells (a few dozen), so with per-value memoization the real cost is small.
Row grouping and aggregation (rowGroup / aggFunc)
Groups view rows by columns with column.rowGroup: true (with several, the order in the columns array is the hierarchy order).
const columns: GridColumn<Order>[] = [
{ key: 'region', title: 'Region', width: 100, rowGroup: true },
{ key: 'rep', title: 'Rep', width: 100, rowGroup: true },
{ key: 'product', title: 'Product', width: 160 },
{ key: 'qty', title: 'Qty', width: 90, align: 'right', aggFunc: 'sum' },
{ key: 'amount', title: 'Amount', width: 120, align: 'right', aggFunc: 'sum' },
];- Grouping from the screen: in tables where any column has
rowGroupwritten (includingfalse), the column menu (⋮) shows "この列でグループ化" (group by this column; adds that column at the bottom of the hierarchy) and, while grouped, "グループ化を外す" (ungroup; removes every level). Both pass column definitions withrowGroupchanged toonColumnsChange(they don't show in tables withoutonColumnsChange). The hierarchy is thecolumnsorder, so grouping by a column that comes before the current group source columns moves it after the last group source column. They don't show on columns with aggregates (aggFunc) or on the last data column shown in the table (grouping it would leave only the auto group column, and it couldn't be undone from the menu). To show only the entry point without grouping at first, writerowGroup: falseon any one column (the items show not only on columns withrowGroupwritten but on every column except aggregate columns and the last data column; there is no per-column setting to hide them). "列のリセット" (reset columns; "すべての列を初期状態に戻す" (reset all columns) in the column menu / tool panel) also puts grouping back to therowGroupof the initial column definitions (since 1.0.1). - Auto group column: when grouping is on, a tree display column (indent + open / close chevron + label + count) is inserted first, and group source columns leave the display automatically. In tables with left pinned columns, the auto group column is pinned left too (first in the left pane, like the expand toggle column; since 0.63.0). The auto group column is a synthetic column and isn't covered by the column menu / sort / reorder DnD / autoSize / export (manual resizing and column range selection work).
- Aggregates: columns with
aggFuncshow the aggregate in the same column position of group rows. The built-ins ('sum' | 'min' | 'max' | 'avg' | 'count') count only numbers (number) and numeric strings (strings thatNumber()makes finite; separated forms like'1,200'aren't included), excluding empty values (null/undefined/''/ whitespace-only strings),true/false,Date, arrays and so on (onlycountis the number of leaf rows below). sum / avg / min / max with 0 numeric values give an empty cell. A custom function (GridAggFunc<T>=({ values, rows, column }) => unknown) shows its return value as is, so it can return a formatted string too. - Formatting aggregates: the same format as the total row (since 0.63.0; before that raw values like
4115.333333showed). Strings as is,countas a count (with separators), the column'svalueFormatterapplied to aggregates too if it has one (so they match leaf cells, e.g.numberFormatter()'s thousands separators), and otherwise numbers with separators + up to 4 decimals (the same for numbers from custom aggregates). Aggregates other than sum (average / min / max / count) show their kind in small text before the value (平均 4,115.33(average)). However, group rows have no leaf row, so the formatter'srowisundefined. Write formatters that readrowso they work without one, as inrow?.x(the formatter also applies when a customaggFuncreturns a number or the like;rowis typedT | undefinedtoo). When a customaggFuncreturns a string, it shows as is without the formatter (the same as the total row; since 0.63.0; before that group rows passed it to the formatter). Aggregates that don't fit the column width end in "…" like the total row, and hovering shows the full text in a tooltip. Averages tend to have long decimals, and in a column of about 100px withnumberFormatter()(up to 3 decimals by default) they get cut like "平均 4,9…". Set the decimals withnumberFormatter({ maximumFractionDigits: 0 })and the like, or widen the column (the format applies to leaf cells too; to round only the aggregate, makeaggFunca function that returns the rounded value). Group counts ("(6,220件)" (6,220 items)) have separators too. - Open / close: click the chevron / double-click the group row /
Enter,Spaceon the group row. Pressing a group row cell makes it the active cell, so you can also press it and then useEnter/Space(the same as moving onto the group row with arrow keys). The imperative API (below) works too. Open / closed state is UI state and isn't covered by undo/redo orgetState(). - Order / filters: groups are ordered by "first appearance after sorting" (sorting a group source column reorders whole groups). Sorting by a column with an aggregate (
aggFunc) also orders groups under the same parent by that aggregate (since 0.63.0; descending by amount puts groups with larger totals on top). Sort conditions are read from the front: if the condition on that level's group source column comes first, that column's order; if the condition on an aggregate column comes first, the aggregate order (empty aggregates last, ties go to the next condition, then first appearance); withmanualSortingnothing is reordered. Group source columns leave the display, but their sorts and column filters still apply (the "並び替えを管理…" (manage sort) panel lists group source columns, not the auto group column. Column filters appear in the filter manager panel's "+ フィルターを追加…" (add filter) as, for example, "地域(グループ化中)" (Region (grouped)), and choosing one opens it below the auto group column's header. Applied filters show in the manager panel and the chip bar as "(グループ化中)" (grouped), reopen with ✎ and are removed with ×). Filters apply to leaf rows, and groups that end up with 0 rows disappear from the display. The global filter (enableGlobalFilter) also searches group source column values ("Kanto" keeps the rows of that region). The tool panel's "列" (Columns) tab shows group source columns as "(グループ化中)" (grouped), and their visibility can't be toggled (their values show in the auto group column). Reordering them by dragging swaps the hierarchy order too (the hierarchy is thecolumnsorder). Empty values gather into one "(空白)" (blank) group. - Features limited to leaves: group rows aren't covered by editing / paste / clear / copy / row selection / export (all cover leaf rows only). Export (scope
'view') outputs every leaf row after filtering / sorting regardless of open / closed state (including those under collapsed groups;isRowExportable'sctx.viewRowIndexis the view row index when everything is expanded). Group source columns hidden from the display go first in the output (a flat table showing which row belongs to which group), andincludeGroupRows: truealso adds a subtotal row at the start of each group (for reports). Counts (the bar's Rows / row selection count) are leaf based too. - Heading text: group row headings are the value's text (
'chubu'). To use the column'svalueFormatterdisplay name, usegroupLabel: 'formatted'; for other text, a function (since 1.1.0; see "Columns whose value and label differ"). - clientSide only: in serverSide (
dataSource),rowGroupis ignored (a development warning).
The group row descriptor is exported from the barrel as GridGroupRow (groupKey / columnKey / value / label / level / leafCount / aggregates / collapsed) (the return value of getGroupRows(); collapsed is whether it is collapsed = since 1.2.0). To save grouping and open / closed state, add includeGroupingInState (see "Saving / restoring state").
Columns whose value and label differ
For columns whose values are codes ('transport' / 'chubu') and whose screen shows labels ("Travel expenses", "Chubu"), show the label with valueFormatter and align the rest with the following three (since 1.1.0). Each defaults to the same as 1.0 (the value's text).
const REGIONS = [
{ value: 'kanto', label: 'Kanto' },
{ value: 'chubu', label: 'Chubu' },
];
const regionLabel = new Map(REGIONS.map((o) => [o.value, o.label]));
const columns: GridColumn<Order>[] = [
{
key: 'region',
title: 'Region',
width: 120,
editable: true,
editor: { type: 'select', options: REGIONS, clipboard: 'label' }, // copy and CSV use labels, and pasted labels become values
valueFormatter: ({ value }) => regionLabel.get(String(value)) ?? String(value ?? ''), // cells show labels
groupLabel: 'formatted', // group row headings show labels too
rowGroup: true,
},
// ...
];
<SpreadsheetGrid columns={columns} globalFilterMatch="both" ... /> // finds both "Chubu" and "chubu"- Group row headings (
groupLabel):'formatted'uses the column'svalueFormatter, and a function its return value (rowis the group's first row). Aggregates use the column's format as before. - Global filter (
globalFilterMatch):'display'matches only the on-screen text (thevalueFormatterresult; "43,340" for anumberFormatter()column), and'both'either the value's text or the on-screen text. Find in cells (find) uses the on-screen text as before. clientSide only; in serverSide the text passed to the server doesn't change (search by label on the server too). - Column filter candidates: the candidates of set / select column filters (the checkbox list) are listed as values (codes) when collected from rows (not through
valueFormatter). To show labels, pass the same candidates ({ value, label }) to the column'sfilterOptions(filterOptions: REGIONS). Condition summaries (the top bar's filter chips, the tool panel) already use labels fromfilterOptionsor the select editor'soptions. Columns withfilterOptionsdon't use the "everything minus unchosen values" form; the condition has only the chosen values (because the candidates don't necessarily cover every value). - Copy / paste / CSV (the select editor's
clipboard: 'label'): copy, CSV / TSV andgetExportData'stextuse the candidate's label (the value's text for candidates with an empty label). Pasted text becomes the value if it is a label, stays as is if it is a value, and is the raw string otherwise (labels are checked first, so even if one candidate's label is the same text as another's value, copying and pasting within the table doesn't change values. Text equal to the current value's label keeps the current value, so re-pasting doesn't change values even for candidates with overlapping labels (since 1.7.0; pasting into another cell gives the first candidate with that label). A candidate chosen in the editor writes its value without conversion. Use the column'svalidatefor marks). Columns withformatClipboardValue/parseClipboardValuewritten use those instead. For non-select columns (columns that only show codes withvalueFormatter), do the same withformatClipboardValue/parseClipboardValue.
Column groups (multi-level column headers) (columnGroups)
Passing column groups to columnGroups adds levels of headers above the column headers that group several columns (since 1.6.0). Groups are written with column keys, and columns can be used as is.
import { SpreadsheetGrid, type GridColumnGroup } from '@ishibashi0112/spreadsheet-grid';
const columnGroups: GridColumnGroup[] = [
{
key: 'tokyo',
title: 'Tokyo warehouse',
collapsible: { keep: ['tokyoTotal'] },
children: [
{ key: 'tokyoH1', title: 'First half', children: ['tokyoApr', 'tokyoMay'] },
'tokyoTotal',
],
},
{ key: 'osaka', title: 'Osaka warehouse', children: ['osakaApr', 'osakaMay'] },
];
<SpreadsheetGrid columns={columns} columnGroups={columnGroups} onColumnsChange={setColumns} … />| Name | Type | Default | Description |
|---|---|---|---|
key | string | (required) | The group's key. A string unique among groups (it may be the same as a column key). Used for open / closed state (closedColumnGroups), setColumnGroupOpen and export's columnGroups. |
title | string | (required) | The name shown in the header. |
children | readonly (string | GridColumnGroup)[] | (required) | Columns inside (the key of columns in columns) and nested groups. Header order is the order of columns; the order of children isn't used. When the same column is in two groups, or two groups have the same key, the one written first is used (a development warning). Keys not in columns are ignored (a development warning). Groups with no columns inside aren't shown. |
collapsible | boolean | { keep?: readonly string[] } | false | Makes the group collapsible. Shows an open / close button in the header, and when closed shows only the columns listed in keep (when unset / none of them is shown, the first shown column in on-screen order; during row grouping, excluding group source columns). When an outer group is closed, only the outer group's keep decides (the open / closed state of inner groups comes back when it opens). Groups that hide no columns when closed (one column / keep covers every column) are treated like non-collapsible groups (no button). |
headerAlign | 'left' | 'center' | 'right' | 'left' | Alignment of the name. 'left' keeps the name at the left of the visible part even when scrolling horizontally, and 'right' keeps it at the right. 'center' is the middle of the group's width (not kept in view). |
className | string | — | A class added to the group's header cell. |
renderHeader | (ctx: ColumnGroupHeaderRenderContext) => ReactNode | — | What to draw in place of the name. ctx = { group, open, collapsible, width } (group is this definition, width the group's width within that pane). The open / close button and the grip are drawn by the grid. Content is cut at the cell's width (it doesn't overflow; truncation (…) is up to the content). Pressing buttons or inputs inside doesn't select columns (the same as a column's renderHeader). It is redrawn when the group scrolls off screen horizontally and when columnGroups changes, so keep the state of components inside outside. |
- Number of levels: decided by the deepest group, and doesn't change with opening / closing or hiding columns. Headers of columns not in a group and of columns in shallow groups extend up to the top levels, with the name at the bottom. The row number, row drag handle, expand toggle and auto group columns (columns the grid adds) aren't in groups either and extend to the top. Level height is
columnGroupHeaderHeight(by default the same as the column header row). - Pinned columns: groups spanning the boundary of left / right pinned columns are split per pane, each showing the name. When columns of the same group are apart (with another column between), the header is split per contiguous run too.
- Moving columns (with
onColumnsChange): a column header can be dragged only within the same group (at positions that leave the group, a vertical line shows at the nearest allowed position; it also looks before and after hidden columns (visible: false, columns hidden by closing) and places it where it doesn't enter another group). Grabbing a group header's grip (⋮⋮) moves the group's columns within that pane together (including columns hidden by closing) (it can be placed only inside the outer group; ghost + vertical line even withcolumnDragMotion: 'live'). Moving across pinned panes changes the columns' pinning too (carrying columns of a group into a pinned pane splits the group per pane). A column unpinned from the column menu goes back next to the center columns of the same group. - Width: dragging the right edge of a group header changes the widths of the visible columns inside, keeping their current ratio (respecting each column's
minWidth/maxWidth). Double-clicking the group's right edge does nothing (auto-fit widths from a column header's right edge or the column menu). - Selecting: pressing a group header selects the group's columns within that pane together (with
Shift, extends from the current selection (a column selection or the active cell; groups pressed before stay whole). Moving sideways while pressing extends while keeping the group's columns). - Open / close:
collapsiblegroups open and close with the header's button orsetColumnGroupOpen(key, open). The top of the column menu (Alt+↓on the active cell, or the header's ⋮) also shows "… を閉じる" (close …) / "… を開く" (open …) for the collapsible groups that contain that column (from the outside in; groups inside a closed group aren't shown). Use this to open and close with the keyboard only. Every change callsonColumnGroupOpenChange({ groupKey, open, closedGroups }). Columns hidden by closing aren't in selection / copy / find / export, the same as hidden columns (the column'svisibledoesn't change). The active cell and selection follow their columns through opening and closing (what was on hidden columns moves to the column the group keeps; the selection shrinks to the selected columns that remain). The horizontal scroll position doesn't change. Closed groups are ingetState()'sclosedColumnGroups(opening / closing also callsonStateChange) and can be restored withinitialState/applyState. Resetting columns (column menu / tool panel) puts back only the column definitions, not the open / closed state. - Columns with the same name: the sort and filter panels, the add-filter picker, filter chips, the bar's sort text and the filter popover's heading prefix group names, as far as needed to tell them apart, only when there are columns with the same name (
title) ("Q1 › Diff"; "Tokyo › Q1 › Diff" if those are the same per warehouse). Column headers and the bar'sslotContext.columnsdon't change. - Export: not included by default. With
includeColumnGroups: trueinexportCsv/getExportData, group levels are output before the header row (CSV writes the name only in the group's first column;getExportDatahas{ key, title, start, span }per level incolumnGroups). The number of levels doesn't change, as on screen, so hiding every column of a deep level makes that level an empty row (an empty array ingetExportData). - Tool panel: the "列" (Columns) tab lists columns grouped (nested groups indented one step each). A group's check is checked when all columns inside are shown and "−" when some are, and pressing it hides the columns inside together (when all are shown; the first column stays if no shown column would remain) or shows them together (while filtered by search, only the visible columns inside). Search matches group names too, and a column's grip can move it only within the same group (the same as dragging column headers).
- Screen readers:
role="row"per level, group headers arerole="columnheader"+aria-colspan(see "Accessibility").