Ga naar hoofdinhoud

CnCard

Generic prop-driven card for rendering an entity with a title, icon, description, labels, stats, and optional footer links/tags. Unlike CnObjectCard (schema-driven) and CnDetailCard (detail-page section container), CnCard is a flexible building block for fixed-structure entities where you pass each piece of content explicitly.

The title auto-detects truncation and shows the full text as a tooltip when ellipsized. The card can be marked active to show a colored highlight border, or clickable to add hover feedback and emit a click event.

Usage

<!-- Basic card with stats -->
<CnCard
title="My Source"
description="A PostgreSQL data source"
:icon="DatabaseArrowRightOutline"
:stats="[
{ label: 'Type', value: 'PostgreSQL' },
{ label: 'Rows', value: 128430 },
]">
<template #actions>
<NcActions>
<NcActionButton @click="edit">Edit</NcActionButton>
</NcActions>
</template>
</CnCard>

<!-- Active state with labels -->
<CnCard
title="My Organisation"
:icon="OfficeBuilding"
:active="isActive"
active-variant="success"
:labels="[
{ text: 'Default', variant: 'warning' },
{ text: 'Active', variant: 'success' },
]" />

<!-- Clickable with footer links and tags -->
<CnCard
title="Documentation"
description="Reference guide"
:clickable="true"
:footer-links="[{ url: 'https://example.org/docs', label: 'Read more' }]"
:tags="['vue', { text: 'stable', variant: 'success' }]"
@click="openDetail" />

Props

PropTypeDefaultDescription
titleString''Card title text. Auto-ellipsizes; full text shown as tooltip when truncated.
descriptionString''Description paragraph, truncated via CSS line-clamp to descriptionLines.
titleTooltipString''Explicit tooltip text for the title. Falls back to description-less behaviour: when unset, the tooltip shows the title only while ellipsized.
iconObject | FunctionnullVue component reference (typically an imported MDI icon) rendered before the title.
iconSizeNumber20Pixel size passed to the icon component.
labelsArray[]Badge/label objects { text, variant? } displayed inline with the title. variant maps to CnStatusBadge variants: default | primary | success | warning | error | info.
statsArray[]Stat rows { label, value } rendered as label/value pairs in the body.
descriptionLinesNumber3Maximum visible lines for the description before truncation.
activeBooleanfalseHighlight the card with a thicker colored border.
activeVariantString'success'Border color when active. One of success | primary | warning | error | info.
clickableBooleanfalseAdds hover shadow and cursor pointer; required to emit click.
footerLinksArray[]External links { url, label? } rendered as target="_blank" anchors in the footer.
tagsArray[]Footer tags. Each entry is either a string (defaulted to default variant) or { text, variant? }.

Events

EventPayloadDescription
clickMouseEventEmitted when the card is clicked. Only fires while clickable is true.

Slots

SlotDescription
defaultContent rendered between the description and the stats/footer.
iconOverride for the header icon (replaces icon prop rendering).
actionsHeader action area (top right). Typically an NcActions menu.
labelsReplaces the default labels row (use when labels need custom icons or markup).
descriptionReplaces the default description paragraph.
statsReplaces the default stats block.
footerReplaces the entire footer (links + tags).
footer-link-icon-{i}Icon rendered before the i-th footer link (zero-indexed).