Skip to main content

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).

FieldTypeDescription
coverbooleanShow the cover image strip
priorityboolean | { data?: CardShapeItem[] }Show priority badge; data maps priority ids to labels and CSS classes
progressboolean | { showLabel?: boolean }Show progress bar; showLabel adds a percentage label
deadlineboolean | { 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
usersboolean | { max?: number; data?: CardShapeUserItem[] }Show user avatars; max limits visible count, data maps user ids to labels and images
tagsboolean | { max?: number; data?: CardShapeItem[] }Show tag chips; max limits visible count, data maps tag ids to labels and CSS classes
attachmentsbooleanShow attachment count
commentsbooleanShow comment count
descriptionbooleanShow description text
menubooleanShow the ⋯ button that opens an outer CardActionMenu

CardShapeItem:

FieldTypeDescription
idstring | numberUnique identifier
labelstringDisplay text
cssstringOptional CSS class

CardShapeUserItem:

FieldTypeDescription
idstring | numberUnique identifier
labelstringDisplay name
imgstringAvatar 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.

SectionCard fieldRenders when
covercoverImage URL is set; shown as a background strip
prioritypriorityId is set; resolved against priority.data, or getPriorityOptions() without data
deadlinedeadlineValue 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)labelValue is set
descriptiondescriptionText is set
tagstagsArray of ids is non-empty; tags.max keeps the first max tags
progressprogressFraction 0..1 is > 0; shown as a rounded percent (showLabel adds nn%)
usersusersArray of ids or { id } is non-empty; users.max keeps the first max users
attachmentsattachmentsNumber, or array length, is > 0
commentscommentsNumber, 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>
  • 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