You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
sortable?:boolean; // can this column be sorted (default: true)
176
176
align?:'left'|'center'|'right'; // cell text alignment
177
+
color?:string|CellColorFn; // column color — static string or per-cell fn
177
178
}
179
+
180
+
typeCellColorFn= (
181
+
row:Record<string, Value>,
182
+
value:Value,
183
+
fieldId:string,
184
+
) =>string|undefined;
178
185
```
179
186
187
+
### Column coloring (`column.color`)
188
+
189
+
Three shapes, from simplest to most flexible:
190
+
191
+
-**Static** (`string`) — any CSS color. Every cell in the column plus the header gets a soft tint of that color. Good for marking a non-editable column, flagging a column that needs attention, or grouping related columns visually.
192
+
-**Rule array** (`ColorRule[]`) — JSON-serializable conditional formatting. Each rule is `{ when: ColorCondition, color: string }`. Rules evaluate top-down; first match wins. Header stays default in this mode. Works in the JSON config form.
193
+
-**Function** (`CellColorFn`) — `(row, value, fieldId) => string | undefined`. For anything the rule array can't express: palettes, numeric interpolation, cross-field math. Header stays default. Prop-API only (functions aren't JSON-serializable).
194
+
195
+
Tints always blend with `color-mix(… 30%, white)` so dark colors stay readable, and compose cleanly with the row-level `colorBy` tint and the in-search yellow highlight.
196
+
197
+
```tsx
198
+
<MonkeyTable
199
+
columns={[
200
+
{ id: 'Name' },
201
+
// Static: the whole "CreatedAt" column + header reads as a read-only band.
|`contains` / `notContains`|`value: string`| case-insensitive substring on string cells |
233
+
|`empty` / `notEmpty`| — |`null`, `undefined`, `""`, or `[]`|
234
+
|`in` / `notIn`|`values: unknown[]`| value is / isn't one of the list |
235
+
236
+
Every operator accepts an optional `field: string` to compare against a **different** column's value instead of the cell's own — useful for "tint the `Status` cell when `Owner` is empty":
For callers who want to reuse the same evaluator outside the grid (e.g., in a summary widget), `evaluateColorRules(rules, row, value)` is exported too:
Copy file name to clipboardExpand all lines: CHANGELOG.md
+10-1Lines changed: 10 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,6 +6,14 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
6
7
7
## [Unreleased]
8
8
9
+
## [0.6.0] — 2026-04-19
10
+
11
+
### New
12
+
-**Column coloring (`column.color`)** — three shapes, same prop. Pass a CSS color string to tint a whole column (every cell + the header) with a soft blend — good for flagging a non-editable column or grouping related columns visually. Pass a `ColorRule[]` (`{ when: { op, value/values, field? }, color }`) for JSON-serializable Google-Sheets-style conditional formatting; rules evaluate top-down and the first match wins. Operators include `equals`/`notEquals`, `lt`/`lte`/`gt`/`gte`, `contains`/`notContains`, `empty`/`notEmpty`, and `in`/`notIn`; each can optionally compare a different field. For anything the rule array can't express (palettes, numeric interpolation, cross-field math), pass a `(row, value, fieldId) => string | undefined` function instead — prop-API only. The evaluator is exported as `evaluateColorRules(rules, row, value)` so the same rules can be reused outside the grid. See [BROWSER.md → Column coloring](./BROWSER.md#column-coloring-columncolor).
13
+
14
+
### Fixed
15
+
-**Header overflow fade now tints with the column** — when a column uses `color` to tint its header, the right-edge fade gradient blends into the tinted background instead of showing a strip of default gray. Symmetric with the row-background fade that already respected `colorBy`.
16
+
9
17
## [0.5.0] — 2026-04-19
10
18
11
19
### New
@@ -118,7 +126,8 @@ First public release.
118
126
-`onUpload` prop — bring your own file upload (S3, Cloudinary, etc.)
Per-column <code>width</code>, <code>minWidth</code>, <code>maxWidth</code>, <code>align</code>, <code>editable</code>, and <code>sortable</code>.
1150
-
SKU and Stock are read-only. SKU is not sortable. Price and Stock are right/center-aligned.
1248
+
Per-column <code>width</code>, <code>minWidth</code>, <code>maxWidth</code>, <code>align</code>, <code>editable</code>, <code>sortable</code>, and
1249
+
{' '}<strong><code>color</code></strong>.
1250
+
SKU and Stock are read-only; SKU is not sortable; Price and Stock are right/center-aligned.
1251
+
<br/>
1252
+
<br/>
1253
+
<strong>Column coloring demo</strong> — three shapes, one prop:
1254
+
<ulstyle={{margin: '6px 0 0 1.2em',padding: 0}}>
1255
+
<li><strong>Static</strong>: <code>SKU</code> uses <code>color: '#f1f5f9'</code> — whole column + header get a soft read-only band.</li>
1256
+
<li><strong>Rule array</strong>: <code>Price</code> uses <code>color: [{ when: { op: 'gte', value: 100 }, color: '#fee2e2' }, { when: { op: 'lt', value: 25 }, color: '#fef9c3' }]</code>. Top-down, first match wins. JSON-serializable, so this works verbatim in <code><MonkeyTableFromConfig></code>.</li>
1257
+
<li><strong>Function</strong>: <code>Stock</code> uses <code>color: (row, value) => …</code> with a three-tier band (red at 0, orange < 100, green > 500). Escape hatch for anything rule data can't express.</li>
1258
+
</ul>
1259
+
Tints compose with row-level coloring (the <em>Row color</em> dropdown on the Editable Table tab) and the search yellow highlight. Higher-priority states — selection, range, drag, Computed fields — still override.
0 commit comments