Skip to main content

CnCard

Generic prop-driven card component for displaying entities with a title, icon, description, labels/badges, stats, and an optional active highlight state.

Unlike CnObjectCard (which derives display from a JSON Schema), CnCard takes explicit props — ideal for known, fixed-structure entities like sources, organisations, and applications.

Props

PropTypeDefaultDescription
titleString''Card title text
descriptionString''Description with line-clamp truncation
titleTooltipString''Tooltip for the title (falls back to description)
iconObject|FunctionnullMDI icon component
iconSizeNumber20Icon size in pixels
labelsArray[]Badge objects: [{ text, variant }] rendered via CnStatusBadge
statsArray[]Stat rows: [{ label, value }] displayed as label:value pairs
descriptionLinesNumber3Max lines for description (CSS line-clamp)
activeBooleanfalseActive/highlighted state with colored border and background
activeVariantString'success'Active color variant: success, primary, warning, error, info
clickableBooleanfalseAdds hover effect and cursor pointer

Labels Format

Each label is an object with text and optional variant:

[
{ text: 'Active', variant: 'success' },
{ text: 'Default', variant: 'warning' },
]

Variants match CnStatusBadge variants: default, primary, success, warning, error, info.

Stats Format

Each stat is an object with label and value:

[
{ label: 'Type', value: 'PostgreSQL' },
{ label: 'Members', value: 12 },
{ label: 'Owner', value: 'Admin' },
]

Events

EventPayloadDescription
clickEventEmitted when card is clicked (only when clickable is true)

Slots

SlotDescription
iconReplace the default icon rendering
labelsReplace the inline badge area
descriptionReplace the description block
defaultContent between description and stats
statsReplace the entire stats section
actionsNcActions menu area (top-right corner)

Usage

Basic Card

<CnCard
title="My Source"
description="A PostgreSQL data source for importing records"
:icon="DatabaseArrowRightOutline"
:stats="[
{ label: 'Type', value: 'PostgreSQL' },
{ label: 'Database URL', value: 'postgres://localhost:5432/mydb' },
]">
<template #actions>
<NcActions :primary="true" menu-name="Actions">
<template #icon>
<DotsHorizontal :size="20" />
</template>
<NcActionButton @click="view(source)">View</NcActionButton>
<NcActionButton @click="edit(source)">Edit</NcActionButton>
<NcActionButton @click="remove(source)">Delete</NcActionButton>
</NcActions>
</template>
</CnCard>

Card with Labels and Active State

<CnCard
:title="organisation.name"
:description="organisation.description"
:icon="OfficeBuilding"
:active="isActive"
active-variant="success"
:labels="[
organisation.isDefault ? { text: 'Default', variant: 'warning' } : null,
isActive ? { text: 'Active', variant: 'success' } : null,
].filter(Boolean)"
:stats="[
{ label: 'Members', value: organisation.users?.length || 0 },
{ label: 'Owner', value: organisation.owner || 'System' },
]">
<template #actions>
<NcActions :primary="true" menu-name="Actions">
<NcActionButton @click="view(organisation)">View</NcActionButton>
<NcActionButton @click="setActive(organisation)">Set Active</NcActionButton>
<NcActionButton @click="edit(organisation)">Edit</NcActionButton>
</NcActions>
</template>
</CnCard>

Card with Status Badge

<CnCard
:title="application.name"
:description="application.description"
:icon="ApplicationOutline"
:labels="[
{
text: application.active ? 'Active' : 'Inactive',
variant: application.active ? 'success' : 'default',
},
]"
:stats="[
application.version ? { label: 'Version', value: application.version } : null,
application.schemas ? { label: 'Schemas', value: application.schemas.length } : null,
application.registers ? { label: 'Registers', value: application.registers.length } : null,
].filter(Boolean)">
<template #actions>
<NcActions :primary="true" menu-name="Actions">
<NcActionButton @click="edit(application)">Edit</NcActionButton>
<NcActionButton @click="remove(application)">Delete</NcActionButton>
</NcActions>
</template>
</CnCard>

Clickable Card

<CnCard
title="Dashboard Item"
description="Click to view details"
:icon="ViewDashboard"
:clickable="true"
@click="navigateToDetail(item)" />