stat-card
One number that matters, with what it is and how it changed: revenue this month, active users, open tickets. change is the change as a percentage (positive or negative), said in words for screen readers ("up 12%"); good says which direction is good ("up" or "down"), so a falling error rate shows as good news.
This one has no events: it shows what it's given.
Source: stat-card.zb, and its registry item.
Install
npx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/stat-card.jsonpnpm dlx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/stat-card.jsonyarn dlx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/stat-card.jsonbunx --bun shadcn@latest add https://zubra-js.github.io/zubra-ui/r/stat-card.json
npx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/element/stat-card.jsonpnpm dlx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/element/stat-card.jsonyarn dlx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/element/stat-card.jsonbunx --bun shadcn@latest add https://zubra-js.github.io/zubra-ui/r/element/stat-card.json
npx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/src/stat-card.jsonpnpm dlx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/src/stat-card.jsonyarn dlx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/src/stat-card.jsonbunx --bun shadcn@latest add https://zubra-js.github.io/zubra-ui/r/src/stat-card.json
<link rel="stylesheet" href="https://zubra-js.github.io/zubra-ui/themes/default.css">
<script type="module" src="https://zubra-js.github.io/zubra-ui/cdn/stat-card.js"></script>The compiled install writes src/components/zubra/stat-card.js and the theme, and adds @zubra/runtime to your dependencies. The one-file install writes the same path as a plain custom element that needs nothing installed (or download it and load it with a <script type="module">); it's smaller on a page with one to three components, the shared runtime with more.
Usage
<stat-card label="Monthly revenue" value="$48,210" period="vs last month"></stat-card>
<script type="module">
import './components/zubra/stat-card.js';
const element = document.querySelector('stat-card');
element.change = 12.4;
</script>import './components/zubra/stat-card.js';
const change = 12.4;
export function StatCardExample() {
return (
<stat-card
label="Monthly revenue"
value="$48,210"
period="vs last month"
change={change}
></stat-card>
);
}<script setup>
import './components/zubra/stat-card.js';
const change = 12.4;
</script>
<template>
<stat-card
label="Monthly revenue"
value="$48,210"
period="vs last month"
:change.prop="change"
></stat-card>
</template>
<!-- vite.config.js: vue({ template: { compilerOptions: { isCustomElement: (tag) => tag.includes('-') } } }) --><script>
import './components/zubra/stat-card.js';
const change = 12.4;
</script>
<stat-card
label="Monthly revenue"
value="$48,210"
period="vs last month"
{change}
></stat-card>import { Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import './components/zubra/stat-card.js';
@Component({
selector: 'app-stat-card-example',
schemas: [CUSTOM_ELEMENTS_SCHEMA],
template: `
<stat-card
label="Monthly revenue"
value="$48,210"
period="vs last month"
[change]="change"
></stat-card>
`,
})
export class StatCardExample {
change = 12.4;
}API
| Property | Type | Default |
|---|---|---|
label | string | "" |
value | string | "" |
change | unknown | null |
good | "up" | "down" | "up" |
period | string | "" |
Size
1.2 KB gzipped for the component, plus the runtime, which every Zubra component on a page shares (up to 22.1 KB, all of it). On its own, with the parts of the runtime it uses, it's 17.4 KB.