columnCss
Callback that returns CSS class name(s) for a column wrapper. Runs once per styled element whenever the projected view data changes. The returned classes are added next to the built-in wx-collapsed state class and any static column.css value.
Usage
columnCss?: (cards: KanbanCard[], column: ColumnView) => string;
Default: undefined
| Parameter | Type | Description |
|---|---|---|
cards | KanbanCard[] | Filtered and sorted cards of the styled element (see below) |
column | ColumnView | Projected column with id, summaries, dataStatus, collapsed, and custom column keys (e.g. wipLimit) |
The cards argument depends on the element that gets the class:
| Element | cards |
|---|---|
Column (.wx-column) or column header | Whole column |
Swimlane cell (.wx-lane-cell) | That lane's cards in the column |
Stack group (.wx-stack-group) | That group's cards (whole column without lanes) |
Returns a space-separated string of CSS class names, or an empty string.
Example
import { Kanban } from "@svar-ui/react-kanban";
const columns = [
{ id: "todo", label: "To Do" },
{ id: "doing", label: "In Progress", wipLimit: 3 },
{ id: "done", label: "Done" },
];
const columnCss = (cards, column) => {
if (column.dataStatus === "loading") return "col-loading";
if (cards.length > column.wipLimit) return "col-wip-exceeded";
if (cards.length === 0) return "col-empty";
return "";
};
<Kanban cards={cards} columns={columns} columnCss={columnCss} />
.col-wip-exceeded {
border-color: var(--wx-color-danger);
}
.col-empty {
opacity: 0.6;
}
.col-loading {
background: repeating-linear-gradient(
-45deg,
transparent,
transparent 8px,
rgba(0,0,0,0.03) 8px,
rgba(0,0,0,0.03) 16px
);
}
Related
- Themes guide - CSS variables, per-card and per-column styling
- cardCss - per-card dynamic CSS classes
- columns - static
cssfield on column definitions