ContextMenu
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:
| Prop | Type | Default | Description |
|---|---|---|---|
api | KanbanInstanceApi | null | null | Kanban instance used to resolve the card and run built-in actions. Until it's set, the menu doesn't open. |
options | any[] | ((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) | null | null | Gate called after card resolution. Return falsy to suppress the menu for that card. |
filter | ((item: any, card: KanbanCard) => boolean) | null | null | Per-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. |
at | string | "point" | Menu placement mode. |
css | string | - | Extra CSS class forwarded to the inner menu. |
The wrapped content (typically <Kanban>) is passed via the default slot.
Methods
| Method | Signature | Description |
|---|---|---|
show | show(ev: Event, obj?: any) | Opens the menu programmatically; obj is the target card ID. |
Built-in item IDs
| ID | Text | Dispatches |
|---|---|---|
edit-card | Edit card | select-card with card id |
duplicate-card | Duplicate card | duplicate-card with card id |
delete-card | Delete card | delete-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>
Related
- Card menu guide - right-click menu, per-card button, custom items
- getMenuOptions - default menu items
- card -
card.menurenders the⋯button thatCardActionMenuopens on