Skip to main content

Columns

Columns are the stages cards move through - "Backlog", "In Progress", "Done", or whatever stages your workflow uses. This guide covers column setup, layout and scroll options, grouping by different fields, and runtime styling.

Defining columns​

To define columns explicitly, pass a columns array. Each entry must have at least an id and a label, the array order sets the left-to-right display order.

<script>
import { Kanban } from "@svar-ui/svelte-kanban";

const columns = [
{ id: "backlog", label: "Backlog" },
{ id: "todo", label: "To Do" },
{ id: "doing", label: "In Progress" },
{ id: "done", label: "Done" },
];

const cards = [];
</script>

<Kanban {cards} {columns} />

Board with four columns showing column headers

A column object supports these fields:

  • id - unique identifier (string or number)
  • label - display text shown in the column header
  • css - static CSS class applied to the column root
  • metadata - freeform object for host-specific data
  • width - fixed outer width in pixels for this column
  • cardWidth / cardHeight - fixed card size that turns the column into a card grid (PRO)
  • summaries - list of summary tags shown in the header
  • addCard - whether the "+" button appears in the header (defaults to true)
  • menu - whether the ⋯ menu button appears in the header (defaults to false)
  • collapsed - initial collapsed state

You can also add your own keys, such as wipLimit or owner. The board copies them to the projected column, so callbacks like columnCss, summary format, and card list slots can read them. Three names are reserved because the board computes them: cards, dataStatus, and summaries (on the projected column, summaries holds the calculated tags, not your definitions).

Columns are shallow-copied on init. Mutating the original array after passing it in won't do anything - change the prop or dispatch update-column.

Columns from data​

The columns prop is optional. Leave it out, and the board builds columns from the cards: one column for each distinct value that the columnAccessor reads.

<script>
import { Kanban } from "@svar-ui/svelte-kanban";

const cards = [
{ id: 1, label: "Plan onboarding", status: "To do" },
{ id: 2, label: "Build search", status: "In progress" },
{ id: 3, label: "Update dependencies", status: "Done" },
{ id: 4, label: "Write release notes", status: "To do" },
];
</script>

<Kanban {cards} columnAccessor="status" />

This board shows three columns: "To do", "In progress", and "Done". Inference follows these rules:

  • Columns appear in the order their ids first appear in the card data.
  • Each label is String(id).
  • Cards with a missing value, or a value that isn't a string or number, add no column.
  • If no card has a column id (or there are no cards), the board shows one unnamed column with all cards. Your card data stays unchanged.

Inferred columns are rebuilt whenever cards or the accessor change. Filtering and sorting don't rebuild them. Since a rebuild replaces the generated configs, empty columns and any runtime changes to inferred columns (a new label, a collapsed state) disappear at the next card change.

Passing any array turns inference off, even an empty one (columns={[]}). For editable boards with a fixed set of stages, pass an explicit columns array.

Column accessor​

By default, each card carries a column field that matches a column id. The columnAccessor prop controls how the store reads and writes that membership.

To use a different property name, pass a string:

<Kanban {cards} {columns} columnAccessor="stage" />

Now every card needs a stage field whose value matches a column id.

When column membership is derived rather than stored as a flat property, pass an object with get and set callbacks:

<script>
const userAccessor = {
get: card => card.user,
set: (card, value) => ({
...card,
user: value,
users: [value],
}),
};
</script>

<Kanban {cards} {columns} columnAccessor={userAccessor} />

get reads the column id from the card. set returns the card object with the updated membership - the board calls it when a user drags a card to another column. set receives a shallow copy of the card, so you can also mutate the argument and return it.

Grouping by other fields​

Switch columnAccessor and columns together to regroup cards by a different dimension without recreating the widget. You can view the same dataset by stage, priority, or assignee.

<script>
import { Kanban } from "@svar-ui/svelte-kanban";

const stageColumns = [
{ id: "backlog", label: "Backlog" },
{ id: "todo", label: "To Do" },
{ id: "doing", label: "In Progress" },
];

const priorityColumns = [
{ id: 1, label: "Low" },
{ id: 2, label: "Medium" },
{ id: 3, label: "High" },
];

let groupBy = $state("stage");

const columns = $derived(
groupBy === "stage" ? stageColumns : priorityColumns
);
const columnAccessor = $derived(groupBy === "stage" ? "stage" : "priority");
</script>

<Kanban {cards} {columns} {columnAccessor} />

When the accessor is a string, each card must have that field with a value matching one of the column ids. With a get/set object, get decides which column each card belongs to.

Column header actions​

Each column header has a collapse toggle and an add-card button. You can also add a ⋯ menu button and a right-click menu.

The collapse toggle is always present. Clicking it dispatches update-column to flip the collapsed flag. Collapsed columns show an expand button and a rotated label but don't render their card list. Collapse works even in readonly mode.

The add-card button shows when addCard isn't explicitly false and readonly is off. Clicking it creates a new card in that column and opens the editor.

To hide the button on specific columns, set addCard: false:

<script>
const columns = [
{ id: "backlog", label: "Backlog" },
{ id: "done", label: "Done", addCard: false },
];
</script>

Column menu​

Set menu: true on a column to show a ⋯ button in its header, between the summary tags and the "+" button. The board renders only the button. To open a menu on click, wrap <Kanban> in <ColumnActionMenu>. To open the same menu on header right-click, wrap it in <ColumnContextMenu>. The right-click menu works on every column, with or without menu: true.

<script>
import {
Kanban,
ColumnActionMenu,
ColumnContextMenu,
} from "@svar-ui/svelte-kanban";

let api = $state();

const columns = [
{ id: "todo", label: "To Do", menu: true },
{ id: "doing", label: "In Progress", menu: true },
{ id: "done", label: "Done" },
];
</script>

<ColumnContextMenu {api}>
<ColumnActionMenu {api}>
<Kanban bind:this={api} {cards} {columns} />
</ColumnActionMenu>
</ColumnContextMenu>

Both wrappers show the default items from getColumnMenuOptions(). The ⋯ button takes some header space, so widen the column or turn off other header features if the label gets too short. For custom items and handlers, see the menu guide.

Column summaries​

Summaries are small tags in the column header, such as total effort, the number of blocked cards, or a 3/5 capacity counter. Define them in the column's summaries array. Each summary has:

  • id - unique key within the column
  • calculate(cards, column) - returns a value from the column's cards
  • format(value, column) - optional, returns the tag text (defaults to String(value))
  • css(value, column) - optional, returns CSS classes for this tag only
<script>
import { Kanban } from "@svar-ui/svelte-kanban";

const summaries = [
{
id: "effort",
calculate: cards =>
cards.reduce((sum, card) => sum + (card.estimateHours ?? 0), 0),
format: value => (value ? `${value} h` : ""),
css: value => (value > 40 ? "effort-over-capacity" : ""),
},
{
id: "blocked",
calculate: cards => cards.filter(card => card.blocked).length,
format: value => (value ? `${value} blocked` : ""),
},
];

const columns = [
{ id: "todo", label: "To do", summaries },
{ id: "doing", label: "Doing", summaries },
{ id: "done", label: "Done", summaries },
];
</script>

<Kanban {cards} {columns} />

Column headers with summary tags for total effort and blocked cards

calculate gets the column's cards after filtering and sorting, across all swimlanes. The board recalculates summaries after every card change, filter, sort, data load, column update, and undo/redo.

To hide a tag, return null or undefined from calculate or format, or return blank text. Above, format returns "" for zero, so empty values don't clutter the header. Empty columns show no tags at all. If a callback throws, the board logs the error and skips only that tag.

WIP limits​

Use a summary for a work-in-progress limit. Store the limit in a custom column key, count the cards, and compare:

<script>
import { Kanban } from "@svar-ui/svelte-kanban";

const capacity = {
id: "capacity",
calculate: cards => cards.length,
format: (value, column) => `${value}/${column.wipLimit}`,
css: (value, column) =>
value > column.wipLimit ? "capacity-exceeded" : "",
};

const columns = [
{ id: "todo", label: "To do", wipLimit: 5, summaries: [capacity] },
{ id: "doing", label: "Doing", wipLimit: 3, summaries: [capacity] },
{ id: "done", label: "Done" },
];

function columnCss(cards, column) {
return column.wipLimit && cards.length > column.wipLimit
? "column-over-limit"
: "";
}
</script>

<Kanban {cards} {columns} {columnCss} />

<style>
:global(.wx-column-summary.capacity-exceeded) {
color: var(--wx-color-danger);
}
:global(.wx-column.column-over-limit) {
background: #fdecec;
}
</style>

The summary's css styles only the tag. To color the whole column, use columnCss: the projected column carries the same wipLimit key. The limit is soft. Cards can still move into a full column. Tag styles need at least .wx-column-summary.your-class specificity to override the defaults.

To replace or remove summaries at runtime, dispatch update-column with a new summaries array (summaries: [] clears them).

Card list slots​

Use cardListStart and cardListEnd to render your own component above or below the cards in each column, for example a column intro or an "Add card" button at the end of the list.

<script>
import { Kanban } from "@svar-ui/svelte-kanban";
import CardListStart from "./CardListStart.svelte";
import CardListEnd from "./CardListEnd.svelte";
</script>

<Kanban
{cards}
{columns}
cardListStart={CardListStart}
cardListEnd={CardListEnd}
/>

Each slot component receives CardListSlotProps:

  • column - the projected column
  • swimlane - the swimlane, for a swimlane cell or stack group only
  • cards - all filtered and sorted cards of this list, including ones outside the virtual range
  • readonly - the board's readonly state
<!-- CardListStart.svelte -->
<script>
let { column, cards } = $props();
</script>

<div class="intro">
<strong>{column.label}</strong>
<span>{cards.length} cards</span>
</div>

Slots scroll with the cards. They aren't cards: you can't drag them, they don't count as items, and double-clicking them doesn't add a card. When a user drops a card over the start slot, the card goes to the start of the list. A drop over the end slot puts it at the end. Slots don't render in collapsed columns or in exports.

The slots do nothing by themselves. Any action, such as adding a card through api.exec("add-card", ...), is your code, and it should respect readonly. See cardListStart and cardListEnd.

Layout: scroll and width​

The render prop controls column layout and scrolling. Two independent settings drive it: columnScroll and fixedColumnWidth.

Scroll modes​

render.columnScroll sets whether each column scrolls independently or the whole board shares one vertical scrollbar.

  • columnScroll: true (default) - each column has its own vertical scrollbar. Headers stay pinned at the top of each column.
  • columnScroll: false - the board becomes one tall scroll surface. All columns scroll together, and headers stick to the top of the viewport.
<Kanban {cards} {columns} render={{ columnScroll: false }} />

Swimlanes and the stack layout always use board scroll and ignore columnScroll.

Column width​

render.fixedColumnWidth controls whether columns have a uniform pixel width or share the available space.

  • fixedColumnWidth: true (default) - every column is 280px wide. Horizontal scrolling appears when the columns overflow the viewport.
  • fixedColumnWidth: false - columns share the viewport width equally, with a minimum floor of 240px each. Horizontal scrolling appears only when the total minimum width exceeds the viewport.
<Kanban {cards} {columns} render={{ fixedColumnWidth: false }} />

These two settings are orthogonal. All four combinations work:

columnScrollfixedColumnWidthResult
truetrueClassic board. Each column scrolls independently, fixed width.
truefalseColumns fill the viewport, each scrolls independently.
falsetrueBoard-wide scroll with sticky headers, fixed-width columns.
falsefalseBoard-wide scroll with sticky headers, columns fill viewport.

Per-column width​

Set width on a column to give it a fixed outer width in pixels. It overrides both fixedColumnWidth modes for that column:

<script>
const columns = [
{ id: "backlog", label: "Backlog", width: 360 },
{ id: "doing", label: "In Progress" },
{ id: "done", label: "Done", width: 200 },
];
</script>

<Kanban {cards} {columns} />

Columns without width keep the default sizing. The board doesn't widen an explicit width to fit content. A collapsed column is still 40px wide. With swimlanes, lane cells use the same width as their column.

Card grid (PRO)​

By default, cards in a column stack vertically, and each card is as tall as its content. Set cardWidth and cardHeight on a column to lay its cards out as a grid of fixed-size tiles instead:

<script>
import { Kanban } from "@svar-ui/svelte-kanban";
import TileCard from "./TileCard.svelte";

const columns = [
{ id: "backlog", label: "Backlog" },
{
id: "design",
label: "Design",
width: 480,
cardWidth: 220,
cardHeight: 140,
},
{ id: "review", label: "Review", cardWidth: 160, cardHeight: 100 },
];
</script>

<Kanban {cards} {columns} cardContent={TileCard} />

Column in card grid mode with fixed-size cards arranged in rows

The grid fits as many cards per row as the column width allows, so a wider column shows more cards per row. If you set only one side, the other defaults to 220 (cardWidth) or 140 (cardHeight). Cards are clipped to their box, so make sure your card template fits the size. A compact cardContent component works best.

Grid columns work with both scroll modes, swimlanes, cardCss, and columnCss. In the MIT edition, the board ignores cardWidth and cardHeight, and every column uses the regular card stack.

Performance​

For large boards, the render prop offers virtualization options that keep the DOM small while the store holds the full dataset.

Card virtualization​

Set render.virtualizeCards to render only the cards visible in the scroll viewport, plus a configurable overscan buffer:

<Kanban
{cards}
{columns}
render={{
virtualizeCards: true,
estimatedCardHeight: 96,
cardOverscan: 8,
}}
/>
  • estimatedCardHeight - height guess in pixels for unmeasured cards. Defaults to 80.
  • cardOverscan - extra cards rendered above and below the visible area. Defaults to 5.

The board measures heights after the first render and caches them by card id. The cache survives reorder, filter, and sort. In flex-width mode, width changes invalidate the cache automatically so cards re-measure.

Column virtualization​

Set render.virtualizeColumns to skip rendering card content for off-screen columns:

<Kanban
{cards}
{columns}
render={{
virtualizeColumns: true,
columnOverscan: 1,
}}
/>

Column shells (headers, collapse state, summary tags, card list slots) stay in the DOM - the board skips only the card list inside off-screen columns. That keeps scroll geometry and drop-target lookup intact.

  • columnOverscan - extra columns rendered beyond the visible area on each side. Defaults to 1.

Card and column virtualization are independent, so you can combine them.

Updating columns at runtime​

Call api.exec("update-column", ...) to patch a column after the board mounts. Pass the column id and a partial object with the fields to change.

<script>
import { Kanban } from "@svar-ui/svelte-kanban";

let api;

function renameColumn() {
api.exec("update-column", {
id: "doing",
column: { label: "Work in Progress" },
});
}

function collapseColumn() {
api.exec("update-column", {
id: "done",
column: { collapsed: true },
});
}
</script>

<Kanban bind:this={api} {cards} {columns} />

You can change any ColumnConfig field: label, css, summaries, menu, width, collapsed, addCard, custom keys, and so on.

Adding, removing, and reordering columns​

Three more actions change the column list itself:

<script>
import { Kanban } from "@svar-ui/svelte-kanban";

let api;

function addColumn() {
// inserts "Review" before "done"; omit `before` to append
api.exec("add-column", {
column: { id: "review", label: "Review" },
before: "done",
});
}

function moveColumn() {
// moves "backlog" to the end
api.exec("move-column", { id: "backlog" });
}

function deleteColumn() {
api.exec("delete-column", { id: "review" });
}
</script>

<Kanban bind:this={api} {cards} {columns} />
  • add-column inserts a column config. Without an id, the board generates one. The label defaults to String(id). Adding an existing id does nothing.
  • delete-column removes the column config.
  • move-column places the column before the before column, or at the end when before is omitted.

These actions change only the column configs. Cards stay untouched. Cards of a deleted column stay in the data but don't render until a column with that id comes back. All three actions also clear the undo/redo history.

For a ready-made UI to manage columns, see GroupManager (PRO).

Styling columns​

Columns accept CSS classes in two ways: statically per definition or dynamically via a callback.

Static classes​

Set css on a column definition to apply a class unconditionally:

<script>
const columns = [
{ id: "backlog", label: "Backlog", css: "column-muted" },
{ id: "doing", label: "In Progress" },
];
</script>

Dynamic classes​

Pass columnCss to compute classes at render time based on a column's cards and state:

<Kanban
{cards}
{columns}
columnCss={(items, column) => {
if (items.length === 0) return "column-empty";
return "";
}}
/>

The first argument is the filtered and sorted card array of the styled element, and the second is the projected column view. On a regular board, that element is the whole column. With swimlanes, columnCss also styles each lane cell and gets only that cell's cards. In the stack layout, it styles each group and gets that group's cards. The board appends the returned string to the element's class list after any static css value and the built-in wx-collapsed modifier.

Built-in CSS classes​

The board applies these classes automatically:

  • wx-column - always present on the column root
  • wx-collapsed - set when the column is collapsed

Target these in your stylesheet to customize column states.