Skip to main content

columnAccessor

Controls how the store reads and writes a card's column membership. Accepts a plain property name as a string, or an object with get/set callbacks for derived membership (e.g., grouping cards by priority or user instead of a literal column field).

Usage​

columnAccessor?: string | {
get: (card: KanbanCard) => ColumnID;
set: (card: KanbanCard, value: ColumnID) => KanbanCard; // receives a shallow copy
};

Default: "column"

With a string, the store reads card[columnAccessor] to find a card's column and writes the same key on move. With an object:

  • get(card) - returns the column ID for a given card
  • set(card, value) - receives a shallow copy of the card and returns it with the column membership updated to value; mutating and returning the argument is safe

If the columns prop isn't set, the store infers columns from the values the accessor reads - one column per distinct value, labelled with that value.

The Pro-only swimlaneAccessor prop has the same shape and reads/writes a card's lane membership (default "swimlane").

Example​

String shorthand (default behavior):

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

const cards = [
{ id: 1, label: "Task A", status: "todo" },
{ id: 2, label: "Task B", status: "doing" },
];

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

<template>
<Kanban :cards="cards" :columns="columns" columnAccessor="status" />
</template>

Object form for derived membership:

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

const cards = [
{ id: 1, label: "Task A", priority: 1 },
{ id: 2, label: "Task B", priority: 3 },
];

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

const columnAccessor = {
get: (card) => card.priority,
set: (card, value) => ({ ...card, priority: value }),
};
</script>

<template>
<Kanban :cards="cards" :columns="columns" :columnAccessor="columnAccessor" />
</template>
  • Columns guide - grouping cards by different fields
  • columns - column definitions the accessor resolves against
  • cards - card objects whose membership the accessor reads