Skip to main content

ContextMenu

warning

ContextMenu is deprecated. It's an alias of CardContextMenu, which opens the menu on right click. For the card ⋯ button (card.menu), use CardActionMenu. Both are described in the Card menu guide.

Right-click menu wrapper that resolves the clicked card and dispatches built-in actions. Wrapping <Kanban> in <ContextMenu> adds edit, duplicate, and delete items on right click, with no extra setup. Custom entries and per-card gating are optional.

Usage​

import { CardContextMenu } from "@svar-ui/vue-kanban";
// deprecated alias:
import { ContextMenu } from "@svar-ui/vue-kanban";

Props​

Shared KanbanMenuProps of the kanban menu wrappers:

PropTypeDefaultDescription
apiKanbanInstanceApi | nullnullKanban instance used to resolve the card and run built-in actions. Until it's set, the menu doesn't open.
optionsany[] | ((card: KanbanCard) => any[] | null | undefined | false)getMenuOptions()Menu items, or a function called with the card on every open. An empty result keeps the menu closed.
resolver((card: KanbanCard, ev: MouseEvent) => any) | nullnullGate called after card resolution. Return falsy to suppress the menu for that card.
filter((item: any, card: KanbanCard) => boolean) | nullnullPer-item visibility filter. Return false to hide an item for the current card.
onclick(ev: any) => void-Fires after built-in handling for a chosen item. Receives { action, context } where action.id is the item id and context is the card.
atstring"point"Menu placement mode.
cssstring-Extra CSS class forwarded to the inner menu.

The wrapped content (typically <Kanban>) is passed via the default slot.

Methods​

MethodSignatureDescription
showshow(ev: Event, obj?: any)Opens the menu programmatically; obj is the target card ID.

Built-in item IDs​

IDTextDispatches
edit-cardEdit cardselect-card with card id
duplicate-cardDuplicate cardduplicate-card with card id
delete-cardDelete carddelete-card with card id

Custom item IDs don't auto-dispatch. Handle them in onclick.

Example​

Default right-click menu:

<ContextMenu :api="api">
<Kanban ref="api" :cards="cards" :columns="columns" />
</ContextMenu>
<Editor v-if="api" :api="api" />

Extended menu with a custom action:

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

const api = ref(null);
const options = [
...getMenuOptions(),
{ id: "archive", text: "Archive", icon: "wxi-empty" },
];

function onclick({ action, context }) {
if (action.id === "archive") {
api.value.exec("update-card", {
id: context.id,
card: { archived: true },
});
}
}
</script>

<template>
<ContextMenu :api="api" :options="options" :onclick="onclick">
<Kanban ref="api" :cards="cards" :columns="columns" />
</ContextMenu>
</template>

Gated menu - block for read-only cards, hide delete for locked cards:

<template>
<ContextMenu
:api="api"
:resolver="(card) => !card.readOnly"
:filter="(item, card) => !(card.locked && item.id === 'delete-card')"
>
<Kanban ref="api" :cards="cards" :columns="columns" />
</ContextMenu>
</template>
  • Card menu guide - right-click menu, per-card button, custom items
  • getMenuOptions - default menu items
  • card - card.menu renders the ⋯ button that CardActionMenu opens on