Skip to main content

CardMenuButton

Renders the card ⋯ menu button inside a custom cardContent template. A custom template replaces the built-in button, so use this component to keep the card menu. An outer CardActionMenu opens the menu when the user clicks the button.

Usage​

import { CardMenuButton } from "@svar-ui/svelte-kanban";
<CardMenuButton {card} />

Props​

PropTypeDefaultDescription
cardKanbanCard-Required. The card that the menu opens for
cssstring""Extra class names for the button

Details​

The component renders the same button as the built-in card: the wx-menu class, the theme styling, and the localized "Card menu" label. It sets data-card-menu, so CardActionMenu finds the card. It also sets data-action="menu", so a click on the button doesn't select the card. Don't build these attributes by hand.

The button always renders. The template controls when it appears, for example with {#if cardShape.menu}. Without an outer CardActionMenu, the button does nothing.

Example​

Custom card template with a menu button:

<!-- MyCard.svelte -->
<script>
import { CardMenuButton } from "@svar-ui/svelte-kanban";
const { card, cardShape } = $props();
</script>

<div class="my-card">
<strong>{card.label}</strong>
{#if cardShape.menu}<CardMenuButton {card} css="my-card-menu" />{/if}
</div>

Board with the template and the action menu:

<script>
import { Kanban, CardActionMenu } from "@svar-ui/svelte-kanban";
import MyCard from "./MyCard.svelte";

let api;
</script>

<CardActionMenu {api}>
<Kanban
bind:this={api}
{cards}
{columns}
card={{ menu: true }}
cardContent={MyCard}
/>
</CardActionMenu>