Skip to main content

add-column

Inserts a new column into the board configuration, optionally before an existing column. The action leaves cards and per-column load state (columnData) unchanged and resets the undo/redo history.

Usage​

type AddColumnPayload = {
column: Partial<ColumnConfig>;
id?: ColumnID;
before?: ColumnID | null;
};
FieldTypeDescription
columnPartial<ColumnConfig>Configuration of the new column
idColumnIDOptional. ID of the new column; takes precedence over column.id
beforeColumnID | nullOptional. Column to insert before; null, omitted, or an unknown ID appends to the end
  • The ID resolves in this order: payload id, then column.id, then a generated temporary ID (tempID()).
  • label defaults to String(id) when not set.
  • If a column with the same ID already exists, the action does nothing. Numeric and string IDs are distinct (1 and "1" are different columns).
  • After the action runs, the payload holds the resolved id, and column holds the full inserted config.

Trigger​

api.exec("add-column", {
column: { label: "Review" },
before: "done",
});

Observe​

api.on("add-column", ({ id, column }) => {
console.log("column added:", id, column.label);
});

Intercept​

api.intercept("add-column", ({ column }) => {
return !!column.label;
});

Returning false cancels the insert.

Component handler​

<Kanban
cards={cards}
columns={columns}
onAddColumn={({ id }) => console.log("added", id)}
/>