행·칸에 조건부 스타일 주기Conditional styles on rows and cells
rowStyle, rowClassRules, cellStyle, cellClassRules, headerStyle로 값에 따라 행과 칸의 모양을 바꾸고, rowTestId로 테스트용 이름을 달아요.Change how rows and cells look by value with rowStyle, rowClassRules, cellStyle, cellClassRules and headerStyle, and tag rows for tests with rowTestId.
코드Code
탭을 골라 코드를 복사하세요. 위 화면은 이 코드를 그대로 실행한 결과예요.Pick a tab and copy the code. The preview above runs exactly this code.
이 화면은 새 모양 옵션을 켠 모양이에요: density: 'spacious', iconStyle: 'soft', motion: true (코드에 없으면 기본 모양으로 보여요)This preview has the new-look options on: density: 'spacious', iconStyle: 'soft', motion: true (without them in your code you get the default look)
버튼을 누르면 이 예제의 코드가 StackBlitz나 CodeSandbox로 전송돼요. 누르기 전에는 아무것도 보내지 않아요.
<div id="app">
<div id="grid" style="height: 380px"></div>
</div>
<script type="module" src="./main.js"></script>import { createGrid } from 'maxgrid';
import { options, setup } from './example';
const api = createGrid(document.getElementById('grid'), options);
setup(api);const items = ['연필', '노트', '지우개', '가위', '풀', '자', '필통', '스테이플러'];
export const options = {
columns: [
{ id: 'item', title: '품목', width: 130, headerStyle: { fontWeight: 700 } },
{
id: 'price',
title: '가격',
width: 110,
kind: 'number',
cellStyle: (ctx) => (Number(ctx.value) >= 5000 ? { fontWeight: 700 } : null),
},
{
id: 'stock',
title: '재고',
width: 100,
kind: 'number',
cellClassRules: { 'cell-low': (ctx) => Number(ctx.value) <= 5 },
},
{ id: 'note', title: '비고', width: 140 },
],
rows: Array.from({ length: 200 }, (_, i) => {
const stock = (i * 7) % 23;
return {
id: i + 1,
item: `${items[i % items.length]} ${i + 1}`,
price: 500 + ((i * 337) % 9500),
stock,
note: stock === 0 ? '품절' : '',
};
}),
rowKey: 'id',
striped: false,
// 재고가 적은 행의 배경. 값이 바뀌거나 스크롤로 줄이 재사용돼도 값을 따라가요.
rowStyle: (row) => (row.stock <= 5 ? { backgroundColor: 'rgba(255, 200, 0, 0.18)' } : null),
rowClassRules: { low: (row) => row.stock === 0 },
rowTestId: (row, key) => `item-${String(key)}`,
};
const CSS = `
.mxg .cell-low { color: var(--mxg-tone-danger-fg, #b42318); font-weight: 700; }
.mxg .mxg-row.low { font-style: italic; }
`;
// 예제 전용 CSS. 실제 앱에서는 앱 스타일시트에 써요.
export function setup(_api) {
const style = document.createElement('style');
style.textContent = CSS;
document.head.append(style);
return () => style.remove();
}<!doctype html>
<html lang="ko">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>행·칸에 조건부 스타일 주기</title>
</head>
<body>
<div id="grid" style="height: 380px"></div>
<script src="https://cdn.maxmine.com/maxgrid/latest/maxgrid.min.js"></script>
<script>
const items = ['연필', '노트', '지우개', '가위', '풀', '자', '필통', '스테이플러'];
const options = {
columns: [
{ id: 'item', title: '품목', width: 130, headerStyle: { fontWeight: 700 } },
{
id: 'price',
title: '가격',
width: 110,
kind: 'number',
cellStyle: (ctx) => (Number(ctx.value) >= 5000 ? { fontWeight: 700 } : null),
},
{
id: 'stock',
title: '재고',
width: 100,
kind: 'number',
cellClassRules: { 'cell-low': (ctx) => Number(ctx.value) <= 5 },
},
{ id: 'note', title: '비고', width: 140 },
],
rows: Array.from({ length: 200 }, (_, i) => {
const stock = (i * 7) % 23;
return {
id: i + 1,
item: `${items[i % items.length]} ${i + 1}`,
price: 500 + ((i * 337) % 9500),
stock,
note: stock === 0 ? '품절' : '',
};
}),
rowKey: 'id',
striped: false,
// 재고가 적은 행의 배경. 값이 바뀌거나 스크롤로 줄이 재사용돼도 값을 따라가요.
rowStyle: (row) => (row.stock <= 5 ? { backgroundColor: 'rgba(255, 200, 0, 0.18)' } : null),
rowClassRules: { low: (row) => row.stock === 0 },
rowTestId: (row, key) => `item-${String(key)}`,
};
const CSS = `
.mxg .cell-low { color: var(--mxg-tone-danger-fg, #b42318); font-weight: 700; }
.mxg .mxg-row.low { font-style: italic; }
`;
// 예제 전용 CSS. 실제 앱에서는 앱 스타일시트에 써요.
function setup(_api) {
const style = document.createElement('style');
style.textContent = CSS;
document.head.append(style);
return () => style.remove();
}
options.ariaLabel = "행·칸에 조건부 스타일 주기";
const api = MaxGrid.createGrid(document.getElementById('grid'), options);
setup(api);
</script>
</body>
</html>버튼을 누르면 이 예제의 코드가 StackBlitz나 CodeSandbox로 전송돼요. 누르기 전에는 아무것도 보내지 않아요.
import { useEffect } from 'react';
import { Grid, useGridApi } from '@maxgrid/react';
import { options, setup, type Row } from './example';
export function ExampleGrid() {
const [api, gridRef] = useGridApi<Row>();
useEffect(() => (api ? setup(api) : undefined), [api]);
return (
<>
<Grid style={{ height: 380 }} ref={gridRef} options={options} />
</>
);
}import type { GridApi, GridOptions } from '@maxgrid/react';
export interface Row {
id: number;
item: string;
price: number;
stock: number;
note: string;
}
const items = ['연필', '노트', '지우개', '가위', '풀', '자', '필통', '스테이플러'];
export const options: GridOptions<Row> = {
columns: [
{ id: 'item', title: '품목', width: 130, headerStyle: { fontWeight: 700 } },
{
id: 'price',
title: '가격',
width: 110,
kind: 'number',
cellStyle: (ctx) => (Number(ctx.value) >= 5000 ? { fontWeight: 700 } : null),
},
{
id: 'stock',
title: '재고',
width: 100,
kind: 'number',
cellClassRules: { 'cell-low': (ctx) => Number(ctx.value) <= 5 },
},
{ id: 'note', title: '비고', width: 140 },
],
rows: Array.from({ length: 200 }, (_, i) => {
const stock = (i * 7) % 23;
return {
id: i + 1,
item: `${items[i % items.length] as string} ${i + 1}`,
price: 500 + ((i * 337) % 9500),
stock,
note: stock === 0 ? '품절' : '',
};
}),
rowKey: 'id',
striped: false,
// 재고가 적은 행의 배경. 값이 바뀌거나 스크롤로 줄이 재사용돼도 값을 따라가요.
rowStyle: (row) => (row.stock <= 5 ? { backgroundColor: 'rgba(255, 200, 0, 0.18)' } : null),
rowClassRules: { low: (row) => row.stock === 0 },
rowTestId: (row, key) => `item-${String(key)}`,
};
const CSS = `
.mxg .cell-low { color: var(--mxg-tone-danger-fg, #b42318); font-weight: 700; }
.mxg .mxg-row.low { font-style: italic; }
`;
// 예제 전용 CSS. 실제 앱에서는 앱 스타일시트에 써요.
export function setup(_api: GridApi<Row>) {
const style = document.createElement('style');
style.textContent = CSS;
document.head.append(style);
return () => style.remove();
}버튼을 누르면 이 예제의 코드가 StackBlitz나 CodeSandbox로 전송돼요. 누르기 전에는 아무것도 보내지 않아요.
<script setup lang="ts">
import { onBeforeUnmount, shallowRef } from 'vue';
import { Grid, type GridApi } from '@maxgrid/vue';
import { options, setup, type Row } from './example';
const api = shallowRef<GridApi<Row> | null>(null);
let stop: (() => void) | undefined;
function onReady(event: { api: GridApi<Row> }) {
api.value = event.api;
stop = setup(event.api);
}
onBeforeUnmount(() => stop?.());
</script>
<template>
<Grid style="height: 380px" :options="options" @ready="onReady" />
</template>import type { GridApi, GridOptions } from '@maxgrid/vue';
export interface Row {
id: number;
item: string;
price: number;
stock: number;
note: string;
}
const items = ['연필', '노트', '지우개', '가위', '풀', '자', '필통', '스테이플러'];
export const options: GridOptions<Row> = {
columns: [
{ id: 'item', title: '품목', width: 130, headerStyle: { fontWeight: 700 } },
{
id: 'price',
title: '가격',
width: 110,
kind: 'number',
cellStyle: (ctx) => (Number(ctx.value) >= 5000 ? { fontWeight: 700 } : null),
},
{
id: 'stock',
title: '재고',
width: 100,
kind: 'number',
cellClassRules: { 'cell-low': (ctx) => Number(ctx.value) <= 5 },
},
{ id: 'note', title: '비고', width: 140 },
],
rows: Array.from({ length: 200 }, (_, i) => {
const stock = (i * 7) % 23;
return {
id: i + 1,
item: `${items[i % items.length] as string} ${i + 1}`,
price: 500 + ((i * 337) % 9500),
stock,
note: stock === 0 ? '품절' : '',
};
}),
rowKey: 'id',
striped: false,
// 재고가 적은 행의 배경. 값이 바뀌거나 스크롤로 줄이 재사용돼도 값을 따라가요.
rowStyle: (row) => (row.stock <= 5 ? { backgroundColor: 'rgba(255, 200, 0, 0.18)' } : null),
rowClassRules: { low: (row) => row.stock === 0 },
rowTestId: (row, key) => `item-${String(key)}`,
};
const CSS = `
.mxg .cell-low { color: var(--mxg-tone-danger-fg, #b42318); font-weight: 700; }
.mxg .mxg-row.low { font-style: italic; }
`;
// 예제 전용 CSS. 실제 앱에서는 앱 스타일시트에 써요.
export function setup(_api: GridApi<Row>) {
const style = document.createElement('style');
style.textContent = CSS;
document.head.append(style);
return () => style.remove();
}버튼을 누르면 이 예제의 코드가 StackBlitz나 CodeSandbox로 전송돼요. 누르기 전에는 아무것도 보내지 않아요.
import { Component, OnDestroy } from '@angular/core';
import { GridComponent, isGridEvent, type GridApi, type GridEventMessage } from '@maxgrid/angular';
import { options, setup, type Row } from './example';
@Component({
selector: 'app-example-grid',
standalone: true,
imports: [GridComponent],
template: `
<mx-grid style="height: 380px" [options]="options" [events]="relayed" (gridEvent)="onEvent($event)" />
`,
})
export class ExampleGridComponent implements OnDestroy {
readonly options = options;
readonly relayed = ['ready'] as const;
api: GridApi<Row> | null = null;
private stop: (() => void) | null = null;
onEvent(event: GridEventMessage<Row>): void {
if (isGridEvent(event, 'ready')) {
this.api = event.payload.api;
this.stop = setup(this.api);
}
}
ngOnDestroy(): void {
this.stop?.();
}
}import type { GridApi, GridOptions } from '@maxgrid/angular';
export interface Row {
id: number;
item: string;
price: number;
stock: number;
note: string;
}
const items = ['연필', '노트', '지우개', '가위', '풀', '자', '필통', '스테이플러'];
export const options: GridOptions<Row> = {
columns: [
{ id: 'item', title: '품목', width: 130, headerStyle: { fontWeight: 700 } },
{
id: 'price',
title: '가격',
width: 110,
kind: 'number',
cellStyle: (ctx) => (Number(ctx.value) >= 5000 ? { fontWeight: 700 } : null),
},
{
id: 'stock',
title: '재고',
width: 100,
kind: 'number',
cellClassRules: { 'cell-low': (ctx) => Number(ctx.value) <= 5 },
},
{ id: 'note', title: '비고', width: 140 },
],
rows: Array.from({ length: 200 }, (_, i) => {
const stock = (i * 7) % 23;
return {
id: i + 1,
item: `${items[i % items.length] as string} ${i + 1}`,
price: 500 + ((i * 337) % 9500),
stock,
note: stock === 0 ? '품절' : '',
};
}),
rowKey: 'id',
striped: false,
// 재고가 적은 행의 배경. 값이 바뀌거나 스크롤로 줄이 재사용돼도 값을 따라가요.
rowStyle: (row) => (row.stock <= 5 ? { backgroundColor: 'rgba(255, 200, 0, 0.18)' } : null),
rowClassRules: { low: (row) => row.stock === 0 },
rowTestId: (row, key) => `item-${String(key)}`,
};
const CSS = `
.mxg .cell-low { color: var(--mxg-tone-danger-fg, #b42318); font-weight: 700; }
.mxg .mxg-row.low { font-style: italic; }
`;
// 예제 전용 CSS. 실제 앱에서는 앱 스타일시트에 써요.
export function setup(_api: GridApi<Row>) {
const style = document.createElement('style');
style.textContent = CSS;
document.head.append(style);
return () => style.remove();
}When you click, the example code is sent to StackBlitz or CodeSandbox. Nothing is sent before you click.
<div id="app">
<div id="grid" style="height: 380px"></div>
</div>
<script type="module" src="./main.js"></script>import { createGrid } from 'maxgrid';
import { options, setup } from './example';
const api = createGrid(document.getElementById('grid'), options);
setup(api);const items = [
'Pencil',
'Notebook',
'Eraser',
'Scissors',
'Glue',
'Ruler',
'Pencil case',
'Stapler',
];
export const options = {
columns: [
{ id: 'item', title: 'Item', width: 150, headerStyle: { fontWeight: 700 } },
{
id: 'price',
title: 'Price',
width: 110,
kind: 'number',
cellStyle: (ctx) => (Number(ctx.value) >= 5000 ? { fontWeight: 700 } : null),
},
{
id: 'stock',
title: 'Stock',
width: 100,
kind: 'number',
cellClassRules: { 'cell-low': (ctx) => Number(ctx.value) <= 5 },
},
{ id: 'note', title: 'Note', width: 140 },
],
rows: Array.from({ length: 200 }, (_, i) => {
const stock = (i * 7) % 23;
return {
id: i + 1,
item: `${items[i % items.length]} ${i + 1}`,
price: 500 + ((i * 337) % 9500),
stock,
note: stock === 0 ? 'Sold out' : '',
};
}),
rowKey: 'id',
striped: false,
// Background for low-stock rows. It follows the value when it changes or when scrolling reuses a line.
rowStyle: (row) => (row.stock <= 5 ? { backgroundColor: 'rgba(255, 200, 0, 0.18)' } : null),
rowClassRules: { low: (row) => row.stock === 0 },
rowTestId: (row, key) => `item-${String(key)}`,
};
const CSS = `
.mxg .cell-low { color: var(--mxg-tone-danger-fg, #b42318); font-weight: 700; }
.mxg .mxg-row.low { font-style: italic; }
`;
// Example-only CSS. In a real app, put it in the app stylesheet.
export function setup(_api) {
const style = document.createElement('style');
style.textContent = CSS;
document.head.append(style);
return () => style.remove();
}<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Conditional styles on rows and cells</title>
</head>
<body>
<div id="grid" style="height: 380px"></div>
<script src="https://cdn.maxmine.com/maxgrid/latest/maxgrid.min.js"></script>
<script>
const items = [
'Pencil',
'Notebook',
'Eraser',
'Scissors',
'Glue',
'Ruler',
'Pencil case',
'Stapler',
];
const options = {
columns: [
{ id: 'item', title: 'Item', width: 150, headerStyle: { fontWeight: 700 } },
{
id: 'price',
title: 'Price',
width: 110,
kind: 'number',
cellStyle: (ctx) => (Number(ctx.value) >= 5000 ? { fontWeight: 700 } : null),
},
{
id: 'stock',
title: 'Stock',
width: 100,
kind: 'number',
cellClassRules: { 'cell-low': (ctx) => Number(ctx.value) <= 5 },
},
{ id: 'note', title: 'Note', width: 140 },
],
rows: Array.from({ length: 200 }, (_, i) => {
const stock = (i * 7) % 23;
return {
id: i + 1,
item: `${items[i % items.length]} ${i + 1}`,
price: 500 + ((i * 337) % 9500),
stock,
note: stock === 0 ? 'Sold out' : '',
};
}),
rowKey: 'id',
striped: false,
// Background for low-stock rows. It follows the value when it changes or when scrolling reuses a line.
rowStyle: (row) => (row.stock <= 5 ? { backgroundColor: 'rgba(255, 200, 0, 0.18)' } : null),
rowClassRules: { low: (row) => row.stock === 0 },
rowTestId: (row, key) => `item-${String(key)}`,
};
const CSS = `
.mxg .cell-low { color: var(--mxg-tone-danger-fg, #b42318); font-weight: 700; }
.mxg .mxg-row.low { font-style: italic; }
`;
// Example-only CSS. In a real app, put it in the app stylesheet.
function setup(_api) {
const style = document.createElement('style');
style.textContent = CSS;
document.head.append(style);
return () => style.remove();
}
options.ariaLabel = "Conditional styles on rows and cells";
const api = MaxGrid.createGrid(document.getElementById('grid'), options);
setup(api);
</script>
</body>
</html>When you click, the example code is sent to StackBlitz or CodeSandbox. Nothing is sent before you click.
import { useEffect } from 'react';
import { Grid, useGridApi } from '@maxgrid/react';
import { options, setup, type Row } from './example';
export function ExampleGrid() {
const [api, gridRef] = useGridApi<Row>();
useEffect(() => (api ? setup(api) : undefined), [api]);
return (
<>
<Grid style={{ height: 380 }} ref={gridRef} options={options} />
</>
);
}import type { GridApi, GridOptions } from '@maxgrid/react';
export interface Row {
id: number;
item: string;
price: number;
stock: number;
note: string;
}
const items = [
'Pencil',
'Notebook',
'Eraser',
'Scissors',
'Glue',
'Ruler',
'Pencil case',
'Stapler',
];
export const options: GridOptions<Row> = {
columns: [
{ id: 'item', title: 'Item', width: 150, headerStyle: { fontWeight: 700 } },
{
id: 'price',
title: 'Price',
width: 110,
kind: 'number',
cellStyle: (ctx) => (Number(ctx.value) >= 5000 ? { fontWeight: 700 } : null),
},
{
id: 'stock',
title: 'Stock',
width: 100,
kind: 'number',
cellClassRules: { 'cell-low': (ctx) => Number(ctx.value) <= 5 },
},
{ id: 'note', title: 'Note', width: 140 },
],
rows: Array.from({ length: 200 }, (_, i) => {
const stock = (i * 7) % 23;
return {
id: i + 1,
item: `${items[i % items.length] as string} ${i + 1}`,
price: 500 + ((i * 337) % 9500),
stock,
note: stock === 0 ? 'Sold out' : '',
};
}),
rowKey: 'id',
striped: false,
// Background for low-stock rows. It follows the value when it changes or when scrolling reuses a line.
rowStyle: (row) => (row.stock <= 5 ? { backgroundColor: 'rgba(255, 200, 0, 0.18)' } : null),
rowClassRules: { low: (row) => row.stock === 0 },
rowTestId: (row, key) => `item-${String(key)}`,
};
const CSS = `
.mxg .cell-low { color: var(--mxg-tone-danger-fg, #b42318); font-weight: 700; }
.mxg .mxg-row.low { font-style: italic; }
`;
// Example-only CSS. In a real app, put it in the app stylesheet.
export function setup(_api: GridApi<Row>) {
const style = document.createElement('style');
style.textContent = CSS;
document.head.append(style);
return () => style.remove();
}When you click, the example code is sent to StackBlitz or CodeSandbox. Nothing is sent before you click.
<script setup lang="ts">
import { onBeforeUnmount, shallowRef } from 'vue';
import { Grid, type GridApi } from '@maxgrid/vue';
import { options, setup, type Row } from './example';
const api = shallowRef<GridApi<Row> | null>(null);
let stop: (() => void) | undefined;
function onReady(event: { api: GridApi<Row> }) {
api.value = event.api;
stop = setup(event.api);
}
onBeforeUnmount(() => stop?.());
</script>
<template>
<Grid style="height: 380px" :options="options" @ready="onReady" />
</template>import type { GridApi, GridOptions } from '@maxgrid/vue';
export interface Row {
id: number;
item: string;
price: number;
stock: number;
note: string;
}
const items = [
'Pencil',
'Notebook',
'Eraser',
'Scissors',
'Glue',
'Ruler',
'Pencil case',
'Stapler',
];
export const options: GridOptions<Row> = {
columns: [
{ id: 'item', title: 'Item', width: 150, headerStyle: { fontWeight: 700 } },
{
id: 'price',
title: 'Price',
width: 110,
kind: 'number',
cellStyle: (ctx) => (Number(ctx.value) >= 5000 ? { fontWeight: 700 } : null),
},
{
id: 'stock',
title: 'Stock',
width: 100,
kind: 'number',
cellClassRules: { 'cell-low': (ctx) => Number(ctx.value) <= 5 },
},
{ id: 'note', title: 'Note', width: 140 },
],
rows: Array.from({ length: 200 }, (_, i) => {
const stock = (i * 7) % 23;
return {
id: i + 1,
item: `${items[i % items.length] as string} ${i + 1}`,
price: 500 + ((i * 337) % 9500),
stock,
note: stock === 0 ? 'Sold out' : '',
};
}),
rowKey: 'id',
striped: false,
// Background for low-stock rows. It follows the value when it changes or when scrolling reuses a line.
rowStyle: (row) => (row.stock <= 5 ? { backgroundColor: 'rgba(255, 200, 0, 0.18)' } : null),
rowClassRules: { low: (row) => row.stock === 0 },
rowTestId: (row, key) => `item-${String(key)}`,
};
const CSS = `
.mxg .cell-low { color: var(--mxg-tone-danger-fg, #b42318); font-weight: 700; }
.mxg .mxg-row.low { font-style: italic; }
`;
// Example-only CSS. In a real app, put it in the app stylesheet.
export function setup(_api: GridApi<Row>) {
const style = document.createElement('style');
style.textContent = CSS;
document.head.append(style);
return () => style.remove();
}When you click, the example code is sent to StackBlitz or CodeSandbox. Nothing is sent before you click.
import { Component, OnDestroy } from '@angular/core';
import { GridComponent, isGridEvent, type GridApi, type GridEventMessage } from '@maxgrid/angular';
import { options, setup, type Row } from './example';
@Component({
selector: 'app-example-grid',
standalone: true,
imports: [GridComponent],
template: `
<mx-grid style="height: 380px" [options]="options" [events]="relayed" (gridEvent)="onEvent($event)" />
`,
})
export class ExampleGridComponent implements OnDestroy {
readonly options = options;
readonly relayed = ['ready'] as const;
api: GridApi<Row> | null = null;
private stop: (() => void) | null = null;
onEvent(event: GridEventMessage<Row>): void {
if (isGridEvent(event, 'ready')) {
this.api = event.payload.api;
this.stop = setup(this.api);
}
}
ngOnDestroy(): void {
this.stop?.();
}
}import type { GridApi, GridOptions } from '@maxgrid/angular';
export interface Row {
id: number;
item: string;
price: number;
stock: number;
note: string;
}
const items = [
'Pencil',
'Notebook',
'Eraser',
'Scissors',
'Glue',
'Ruler',
'Pencil case',
'Stapler',
];
export const options: GridOptions<Row> = {
columns: [
{ id: 'item', title: 'Item', width: 150, headerStyle: { fontWeight: 700 } },
{
id: 'price',
title: 'Price',
width: 110,
kind: 'number',
cellStyle: (ctx) => (Number(ctx.value) >= 5000 ? { fontWeight: 700 } : null),
},
{
id: 'stock',
title: 'Stock',
width: 100,
kind: 'number',
cellClassRules: { 'cell-low': (ctx) => Number(ctx.value) <= 5 },
},
{ id: 'note', title: 'Note', width: 140 },
],
rows: Array.from({ length: 200 }, (_, i) => {
const stock = (i * 7) % 23;
return {
id: i + 1,
item: `${items[i % items.length] as string} ${i + 1}`,
price: 500 + ((i * 337) % 9500),
stock,
note: stock === 0 ? 'Sold out' : '',
};
}),
rowKey: 'id',
striped: false,
// Background for low-stock rows. It follows the value when it changes or when scrolling reuses a line.
rowStyle: (row) => (row.stock <= 5 ? { backgroundColor: 'rgba(255, 200, 0, 0.18)' } : null),
rowClassRules: { low: (row) => row.stock === 0 },
rowTestId: (row, key) => `item-${String(key)}`,
};
const CSS = `
.mxg .cell-low { color: var(--mxg-tone-danger-fg, #b42318); font-weight: 700; }
.mxg .mxg-row.low { font-style: italic; }
`;
// Example-only CSS. In a real app, put it in the app stylesheet.
export function setup(_api: GridApi<Row>) {
const style = document.createElement('style');
style.textContent = CSS;
document.head.append(style);
return () => style.remove();
}