card
Controls which built-in sections appear on each card - cover image, priority badge, progress bar, deadline, tags, user avatars, attachment/comment counts, description, and the card menu button. Each section takes a boolean to toggle it or an options object to configure it.
Usage
card?: CardShape;
Default: getCardShape() (enables priority, progress, description, deadline, tags).
| Field | Type | Description |
|---|---|---|
cover | boolean | Show the cover image strip |
priority | boolean | { data?: CardShapeItem[] } | Show priority badge; data maps priority ids to labels and CSS classes |
progress | boolean | { showLabel?: boolean } | Show progress bar; showLabel adds a percentage label |
deadline | boolean | { format?: string | ((date: Date) => string) } | Show deadline; format is a wx format string ("%Y-%m-%d") or a function returning the text. Default: the locale dateFormat |
users | boolean | { max?: number; data?: CardShapeUserItem[] } | Show user avatars; max limits visible count, data maps user ids to labels and images |
tags | boolean | { max?: number; data?: CardShapeItem[] } | Show tag chips; max limits visible count, data maps tag ids to labels and CSS classes |
attachments | boolean | Show attachment count |
comments | boolean | Show comment count |
description | boolean | Show description text |
menu | boolean | Show the ⋯ button that opens an outer CardActionMenu |
CardShapeItem:
| Field | Type | Description |
|---|---|---|
id | string | number | Unique identifier |
label | string | Display text |
css | string | Optional CSS class |
CardShapeUserItem:
| Field | Type | Description |
|---|---|---|
id | string | number | Unique identifier |
label | string | Display name |
img | string | Avatar image URL (optional) |
Section data rules:
A section renders only when its flag is truthy and the card has data for that field. Missing or false entries hide the section.
| Section | Card field | Renders when |
|---|---|---|
cover | cover | Image URL is set; shown as a background strip |
priority | priority | Id is set; resolved against priority.data, or getPriorityOptions() without data |
deadline | deadline | Value is a Date; strings and timestamps aren't parsed |
menu | - | Flag is truthy; the button sits in the header, or after the title without priority or deadline |
| (title) | label | Value is set |
description | description | Text is set |
tags | tags | Array of ids is non-empty; tags.max keeps the first max tags |
progress | progress | Fraction 0..1 is > 0; shown as a rounded percent (showLabel adds nn%) |
users | users | Array of ids or { id } is non-empty; users.max keeps the first max users |
attachments | attachments | Number, or array length, is > 0 |
comments | comments | Number, or array length, is > 0 |
For priority, tags, and users, an id with no matching data entry renders as the raw id.
Example
Enable priority with custom options, tags with lookup data, and the card menu:
<script setup>
import { Kanban } from "@svar-ui/vue-kanban";
const card = {
priority: {
data: [
{ id: 1, label: "Low", css: "wx-card-priority-low" },
{ id: 2, label: "Medium", css: "wx-card-priority-medium" },
{ id: 3, label: "High", css: "wx-card-priority-high" },
],
},
tags: {
data: [
{ id: "bug", label: "Bug" },
{ id: "feature", label: "Feature" },
],
},
users: {
max: 3,
data: [
{ id: 1, label: "Alice", img: "/avatars/alice.png" },
{ id: 2, label: "Bob" },
],
},
description: true,
progress: true,
deadline: { format: "%Y-%m-%d" },
menu: true,
};
</script>
<template>
<Kanban :cards="cards" :columns="columns" :card="card" />
</template>
Start from the defaults and extend:
<script setup>
import { Kanban, getCardShape } from "@svar-ui/vue-kanban";
const card = {
...getCardShape(),
users: { data: users },
menu: true,
};
</script>
<template>
<Kanban :cards="cards" :columns="columns" :card="card" />
</template>
Related
- Cards guide - section visibility, per-section options, and custom card body
- getCardShape - returns the default CardShape
- cardContent - custom card body replacing the default sections
- cardCss - per-card dynamic CSS classes