Marketing sectionsStatsCards
Searchastronomic.dev# StatsCards
To show a few results as large numbers, each on its own card.
Static: no JavaScript.
## Usage
```astro
import StatsCards from "@astronomic-dev/ui/components/StatsCards.astro";
```
## Examples
### Results on cards
Each stat on a card surface, the cards gap-cards apart (20px by default). As many columns as fit, each at least 12rem: one on a phone, three here on a wide page.
```astro
---
import StatsCards from "@astronomic-dev/ui/components/StatsCards.astro";
const stats = [
{ value: "+38%", label: "Inquiries in the first quarter", text: "Against the same quarter a year before." },
{ value: "1.2s", label: "Largest paint on mobile", text: "On a mid-range phone, on 4G." },
{ value: "14", label: "Editors trained", text: "Across three teams." },
];
---
<div class="mx-auto max-w-6xl px-6 py-16">
<StatsCards heading="Results" text="What changed in the first months after launch." items={stats} />
</div>
```
## Props
### StatsCards
| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `items` | `StatItem[]` | None | Required. The stats: { value, label, text? } (StatItem). value shows large, in the stat role, sized to its own item, on one line (never broken mid-number): every value in the list takes the size at which the widest one fits its stat, so short values come out large and 12,500,000+ still fits a 9rem stat; text is one short line under the label. Only these fields render, so a CMS entry's other fields never reach the page. |
| `heading` | `string` | None | The section heading, in the title role in display type. Without it, and without label, a plain <div> holds only the list. |
| `emphasis` | `boolean` | `false` | Turn one *phrase* in the heading into <em>: exactly two asterisks around text with no space inside, as in "Built for *the long run*". Any other asterisks show as typed. Off by default, so the heading shows as typed. How the <em> looks is the theme's. |
| `mark` | `string` | None | A short mark after the heading, such as "(12)" or "©2026", in small muted type. It sits beside the heading, outside it, so the heading's name stays plain. Shown only with a heading. |
| `markLabel` | `string` | None | What the mark says to a screen reader, such as "12 projects": the mark is then hidden from screen readers and this is read in its place. Without it, the mark is read as written. |
| `text` | `string` | None | One or two sentences under the heading, in the lead role, muted. Shown only with a heading. |
| `headingTag` | `"h2" \| "h3" \| "h4"` | `"h2"` | The heading element. |
| `label` | `string` | None | Names the stats when there is no heading: the root is then a <section aria-label>. Ignored with a heading. |
| `class` | `string` | None | More classes for the root (the <section>, or the <div> without a heading or label), merged with cn(), so yours win on conflicts. The root is a named size container (inline-size containment): in a shrink-to-fit parent (inline-flex, a float, fit-content) it collapses, so give it a width there. |
| Slot | Description |
| --- | --- |
| `eyebrow` | A short line above the heading, such as a Badge. Shown only with a heading. |
Any other attribute goes on the <section>, or on the <div> without a heading or label.
## Accessibility
- With a heading, renders a <section> named by it, so it is a region landmark. The heading id is unique on the page.
- Without a heading or a label, renders a plain <div>. Put your own heading above it.
- Each stat is a label (<dt>) and a value (<dd>), the label first, so a screen reader reads 'Projects shipped: 120'. With label and no heading, the stats are a region named by it.
- The value is text, never counted up: what a screen reader reads is what shows.
- An empty items list renders an empty list: leave the section out when there is nothing to show.
StatsCards
FreeTo show a few results as large numbers, each on its own card.
- File
- StatsCards.astro
- Group
- Marketing sections
- Kind
- Static: no JavaScript
- Examples
- 1
Examples
Drag the orange handle to set the width. Frames get real breakpoints.
- Static
- Interactive
- Framed
Results on cards
Each stat on a card surface, the cards gap-cards apart (20px by default). As many columns as fit, each at least 12rem: one on a phone, three here on a wide page.
This preview did not load.
main.astro
examples/statscards/main.astro
---
import StatsCards from "@astronomic-dev/ui/components/StatsCards.astro";
const stats = [
{ value: "+38%", label: "Inquiries in the first quarter", text: "Against the same quarter a year before." },
{ value: "1.2s", label: "Largest paint on mobile", text: "On a mid-range phone, on 4G." },
{ value: "14", label: "Editors trained", text: "Across three teams." },
];
---
<div class="mx-auto max-w-6xl px-6 py-16">
<StatsCards heading="Results" text="What changed in the first months after launch." items={stats} />
</div>Minimal · Light