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/react-kanban";
<CardMenuButton card={card} />
Props
| Prop | Type | Default | Description |
|---|---|---|---|
card | KanbanCard | - | Required. The card that the menu opens for |
css | string | "" | 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 {cardShape.menu && ...}. Without an outer CardActionMenu, the button does nothing.
Example
Custom card template with a menu button:
// MyCard.jsx
import { CardMenuButton } from "@svar-ui/react-kanban";
function MyCard({ card, cardShape }) {
return (
<div className="my-card">
<strong>{card.label}</strong>
{cardShape.menu && <CardMenuButton card={card} css="my-card-menu" />}
</div>
);
}
export default MyCard;
Board with the template and the action menu:
import { useState } from "react";
import { Kanban, CardActionMenu } from "@svar-ui/react-kanban";
import MyCard from "./MyCard.jsx";
function Board({ cards, columns }) {
const [api, setApi] = useState();
return (
<CardActionMenu api={api}>
<Kanban
init={setApi}
cards={cards}
columns={columns}
card={{ menu: true }}
cardContent={MyCard}
/>
</CardActionMenu>
);
}
export default Board;
Related
- cardContent - custom card template
- CardActionMenu - menu that opens from this button
- getMenuOptions - default card menu items