CardActionMenu
Menu wrapper that opens when a card's ⋯ button is clicked. Wrap <Kanban> in <CardActionMenu> and enable the button with card.menu: true, or render CardMenuButton inside a custom cardContent. The menu context is the clicked KanbanCard; the default items come from getMenuOptions().
The wrapper needs the kanban api and stays closed until api is set. Without an outer CardActionMenu, the ⋯ buttons do nothing.
Usage
import { CardActionMenu } from "@svar-ui/vue-kanban";
Props
Props follow the shared KanbanMenuProps<KanbanCard> type.
| Prop | Type | Default | Description |
|---|---|---|---|
api | KanbanInstanceApi | null | null | Kanban instance used to resolve the card and run built-in actions. |
options | any[] | ((card: KanbanCard) => any[] | null | undefined | false) | getMenuOptions() | Menu items, or a function called on every open. An empty result keeps the menu closed. |
resolver | ((card: KanbanCard, ev: MouseEvent) => any) | null | null | Gate called after the card is resolved. Return a falsy value to keep the menu closed. |
filter | ((item: any, card: KanbanCard) => boolean) | null | null | Per-item 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 }. |
at | string | "point" | Menu placement, forwarded to the menu. |
css | string | - | Extra CSS class forwarded to the menu. |
default | slot | - | Wrapped content - <Kanban> or another menu wrapper. |
onclick doesn't fire when the menu closes without a choice (outside click, Escape).
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 | Dispatches |
|---|---|
edit-card | select-card with card id |
duplicate-card | duplicate-card with card id |
delete-card | delete-card with card id |
Built-in items run before onclick. Other item IDs reach only onclick.
Example
Menu on the ⋯ button with a custom item:
<script setup>
import { ref } from "vue";
import {
Kanban,
CardActionMenu,
Editor,
getMenuOptions,
} from "@svar-ui/vue-kanban";
const api = ref();
const options = [
...getMenuOptions(),
{ id: "my-action", text: "My action", icon: "wxi-empty" },
];
function onclick({ action, context }) {
if (action.id === "my-action") console.log("Card:", context.id);
}
</script>
<template>
<CardActionMenu :api="api" :options="options" :onclick="onclick">
<Kanban ref="api" :cards="cards" :columns="columns" :card="{ menu: true }" />
</CardActionMenu>
<Editor v-if="api" :api="api" />
</template>
The same menu on the button and on right click:
<template>
<CardContextMenu :api="api" :options="options" :onclick="onclick">
<CardActionMenu :api="api" :options="options" :onclick="onclick">
<Kanban ref="api" :cards="cards" :columns="columns" :card="{ menu: true }" />
</CardActionMenu>
</CardContextMenu>
</template>
Related
- Menu guide - card and column menus, custom items
- CardContextMenu - card menu on right click
- CardMenuButton -
⋯button for a custom card body - getMenuOptions - default card menu items
- card - enable the
⋯button viacard.menu