Metric card
Displays a key metric or data point in a concise card format, often used in dashboards and analytics views to highlight performance indicators.
Component
Metric title
+120 vs last period
Last 30 days
Props
| Props | Default | Type |
|---|---|---|
styleType | MetricCardStyle.DEFAULT | MetricCardStyle |
title | 'Metric title' | string |
icon | — | string |
backgroundIcon | — | string |
backgroundIconPosition | MetricCardBackgroundIconPosition.MIDDLE | MetricCardBackgroundIconPosition |
backgroundIconContainerClass | — | string |
backgroundIconClass | — | string |
iconContainerShape | IconContainerShape.SQUARE | IconContainerShape |
iconContainerSize | IconContainerSize.SM | IconContainerSize |
iconSize | IconSize.MD | IconSize |
iconPosition | MetricCardIconPosition.LEFT | MetricCardIconPosition |
defaultStyleIconColor | ColorAccent.NEUTRAL | ColorAccent |
defaultStyleIconContainerType | IconContainerStyleType.FILLED | IconContainerStyleType |
amount | — | string | number |
unit | — | string |
featuredDescription | — | string |
description | — | string |
trend | — | string |
trendDirection | MetricTrendDirection.UP | MetricTrendDirection |
customFilledColorClass | 'bg-background-neutral-bold' | string |
trendIconSize | IconSize.SM | IconSize |
cardHeaderClass | — | string |
cardBodyClass | — | string |
cardTitleClass | — | string |
amountClass | — | string |
unitClass | — | string |
descriptionWrapperClass | — | string |
featuredDescriptionClass | — | string |
descriptionClass | — | string |
trendWrapperClass | — | string |
trendTextClass | — | string |
Slots
| Name | Description |
|---|---|
rightTop | Slot to render custom content on the right side of the card header, aligned with the title. Only rendered when `iconPosition` is `LEFT`. |
footer | Slot to render custom content below the trend row, such as actions or supplementary details. |
<template>
<MetricCard
title="Revenue"
:amount="1327"
>
<template #rightTop>
<Badge text="Live" />
</template>
<template #footer>
<ActionButton
text="View Details"
:iconPosition="IconPosition.RIGHT"
icon="mdi:arrow-right"
:actionType="ButtonActionType.LINK"
to="link"
/>
</template>
</MetricCard>
</template>
Usage
styleType
Sets the visual style of the card. It accepts values from the MetricCardStyle enum.
<template>
<MetricCard
:styleType="MetricCardStyle.PRIMARY_BRAND_SOFT"
/>
</template>
Options
| Value | Description |
|---|---|
DEFAULT | Neutral surface background with default text color. |
PRIMARY_BRAND_FILLED | Filled primary brand background with on-filled text color. |
PRIMARY_BRAND_SOFT | Soft primary brand background with brand-on-soft text color. |
SECONDARY_BRAND_FILLED | Filled secondary brand background with on-filled text color. |
SECONDARY_BRAND_SOFT | Soft secondary brand background with brand-on-soft text color. |
NEUTRAL_FILLED | Filled neutral-bold background with on-filled text color. |
NEUTRAL_SOFT | Subtle neutral background with on-neutral text color. |
CUSTOM_FILLED | Applies the class provided through `customFilledColorClass` as the background. |
title
Sets the title of the metric card.
<template>
<MetricCard
title="Revenue"
/>
</template>
icon
Sets the icon shown in the card header. When using a filled styleType, it renders as a plain icon; otherwise it is wrapped in a ContainedIcon.
<template>
<MetricCard
icon="mdi:chart-line"
/>
</template>
backgroundIcon
Sets an optional decorative icon rendered as a large, semi-transparent background element on the right side of the card. It is only displayed when provided and inherits its color from the active styleType. It is hidden from assistive technologies (aria-hidden).
<template>
<MetricCard
backgroundIcon="mdi:earth"
:styleType="MetricCardStyle.PRIMARY_BRAND_FILLED"
title="Global coverage"
:amount="159"
unit="M ha"
/>
</template>
backgroundIconPosition
Sets the vertical alignment of the background icon inside the card. It accepts values from the MetricCardBackgroundIconPosition enum.
<template>
<MetricCard
backgroundIcon="mdi:earth"
:backgroundIconPosition="MetricCardBackgroundIconPosition.TOP"
/>
</template>
Options
| Value | Description |
|---|---|
TOP | Aligns the background icon to the top of the card. |
MIDDLE | Vertically centers the background icon within the card. |
BOTTOM | Aligns the background icon to the bottom of the card. |
backgroundIconContainerClass
Appends Tailwind utility classes to the background icon wrapper element. Use it to override defaults such as opacity-20 or to adjust position.
<template>
<MetricCard
backgroundIcon="mdi:earth"
backgroundIconContainerClass="opacity-10"
/>
</template>
backgroundIconClass
Appends Tailwind utility classes to the background Icon component. The defaults w-[80px]! h-[80px]! apply when this prop is omitted; values passed here are merged after the defaults, so they can override size.
<template>
<MetricCard
backgroundIcon="mdi:earth"
backgroundIconClass="w-[120px]! h-[120px]!"
/>
</template>
iconContainerShape
Sets the shape of the icon container when styleType is DEFAULT. It accepts values from the IconContainerShape enum and has no effect on other style types (which always render with a square container).
<template>
<MetricCard
icon="mdi:chart-line"
:iconContainerShape="IconContainerShape.CIRCLE"
/>
</template>
Options
| Value | Description |
|---|---|
CIRCLE | Renders the icon inside a circular container. |
SQUARE | Renders the icon inside a square container. |
iconContainerSize
Sets the size of the ContainedIcon container rendered for non-filled style types. It accepts values from the IconContainerSize enum and applies regardless of iconPosition.
<template>
<MetricCard
icon="mdi:chart-line"
:iconContainerSize="IconContainerSize.MD"
/>
</template>
Options
| Value | Description |
|---|---|
SM | 24 × 24 px container. |
MD | 32 × 32 px container. |
LG | 40 × 40 px container. |
XL | 48 × 48 px container. |
XXL | 56 × 56 px container. |
XXXL | 80 × 80 px container. |
iconSize
Sets the size of the plain icon rendered when using a filled styleType. It is passed as the size prop to the Icon component and applies regardless of iconPosition. Has no effect on non-filled styles, which use iconContainerSize instead. It accepts values from the IconSize enum.
<template>
<MetricCard
icon="mdi:chart-line"
:styleType="MetricCardStyle.NEUTRAL_FILLED"
:iconSize="IconSize.LG"
/>
</template>
iconPosition
Sets whether the icon appears before or after the title. It accepts values from the MetricCardIconPosition enum.
<template>
<MetricCard
icon="mdi:chart-line"
:iconPosition="MetricCardIconPosition.RIGHT"
/>
</template>
Options
| Value | Description |
|---|---|
LEFT | Renders the icon before the title. |
RIGHT | Renders the icon after the title. |
defaultStyleIconColor
Sets the icon color when styleType is DEFAULT. It accepts values from the ColorAccent enum and has no effect on other style types.
<template>
<MetricCard
:defaultStyleIconColor="ColorAccent.SUCCESS"
/>
</template>
Options
| Value | Description |
|---|---|
NEUTRAL | Neutral accent. |
SUCCESS | Success accent. |
WARNING | Warning accent. |
DANGER | Danger accent. |
INFO | Info accent. |
PRIMARY_BRAND | Primary brand accent. |
SECONDARY_BRAND | Secondary brand accent. |
defaultStyleIconContainerType
Sets the style type of the icon container when styleType is DEFAULT. It accepts values from the IconContainerStyleType enum and has no effect on other style types.
<template>
<MetricCard
icon="mdi:chart-line"
:defaultStyleIconContainerType="IconContainerStyleType.FLAT"
/>
</template>
Options
| Value | Description |
|---|---|
FLAT | Renders the icon container with a flat, transparent background. |
FILLED | Renders the icon container with a filled background. |
amount
Sets the main metric value displayed prominently in the card body.
<template>
<MetricCard
:amount="1327"
/>
</template>
unit
Sets an optional unit shown next to the amount (e.g. /month). It is only rendered when provided.
<template>
<MetricCard
:amount="80"
unit="/month"
/>
</template>
featuredDescription
Sets an optional highlighted description rendered above the regular description in a stronger weight. It is only displayed when provided.
<template>
<MetricCard
featuredDescription="+120 vs last period"
/>
</template>
description
Sets an optional description rendered below the featured description. It is only displayed when provided.
<template>
<MetricCard
description="Last 30 days"
/>
</template>
trend
Sets an optional trend label rendered next to a directional icon. The trend row is only displayed when this prop is provided.
<template>
<MetricCard
trend="+12%"
/>
</template>
trendDirection
Sets the direction of the trend, which determines both the icon and the text color. It accepts values from the MetricTrendDirection enum.
<template>
<MetricCard
trend="+12%"
:trendDirection="MetricTrendDirection.UP"
/>
</template>
Options
| Value | Description |
|---|---|
UP | Upward arrow with success color (or on-filled color on filled styles). |
DOWN | Downward arrow with error color (or on-filled color on filled styles). |
NEUTRAL | Minus icon with neutral-subtle color (or on-filled color on filled styles). |
customFilledColorClass
Sets the Tailwind background class applied when styleType is CUSTOM_FILLED. Use it to render the card with a custom filled background.
<template>
<MetricCard
:styleType="MetricCardStyle.CUSTOM_FILLED"
customFilledColorClass="bg-background-success-bold"
/>
</template>
trendIconSize
Sets the size of the trend direction icon. It accepts values from the IconSize enum.
<template>
<MetricCard
trend="+12%"
:trendIconSize="IconSize.MD"
/>
</template>
cardHeaderClass
Appends Tailwind utility classes to the CardHeader element.
<template>
<MetricCard
cardHeaderClass="pb-0"
/>
</template>
cardBodyClass
Appends Tailwind utility classes to the CardBody element.
<template>
<MetricCard
cardBodyClass="flex-col"
/>
</template>
cardTitleClass
Appends Tailwind utility classes to the CardTitle element.
<template>
<MetricCard
cardTitleClass="text-base"
/>
</template>
amountClass
Appends Tailwind utility classes to the amount value span.
<template>
<MetricCard
:amount="1327"
amountClass="text-4xl"
/>
</template>
unitClass
Appends Tailwind utility classes to the unit span.
<template>
<MetricCard
unit="month"
unitClass="text-base"
/>
</template>
descriptionWrapperClass
Appends Tailwind utility classes to the wrapper element that contains both the featured description and the description.
<template>
<MetricCard
description="Last 30 days"
descriptionWrapperClass="gap-1"
/>
</template>
featuredDescriptionClass
Appends Tailwind utility classes to the featured description paragraph.
<template>
<MetricCard
featuredDescription="+120 vs last period"
featuredDescriptionClass="text-text-success"
/>
</template>
descriptionClass
Appends Tailwind utility classes to the description paragraph.
<template>
<MetricCard
description="Last 30 days"
descriptionClass="text-text-neutral-subtle"
/>
</template>
trendWrapperClass
Appends Tailwind utility classes to the trend row wrapper element.
<template>
<MetricCard
trend="+12%"
trendWrapperClass="mt-1"
/>
</template>
trendTextClass
Appends Tailwind utility classes to the trend label span.
<template>
<MetricCard
trend="+12%"
trendTextClass="font-bold"
/>
</template>