Marketing sectionsStats
Searchastronomic.dev# Stats
To build your own stats layout: a few results as large numbers, each with a label and an optional line. For a ready layout, use StatsGrid or StatsCards.
Static: no JavaScript.
## Usage
```astro
import Stats from "@astronomic-dev/ui/components/Stats.astro";
```
## Examples
### Slots
The section is a shell: the eyebrow, the heading and the text always show in that order, then one list of stats, each a label and a large value with an optional line. The shell sets the type and the gaps; the recipes lay out the list and each stat. StatsGrid and StatsCards are recipes built on it.
```astro
---
import Badge from "@astronomic-dev/ui/components/Badge.astro";
import Stats from "@astronomic-dev/ui/components/Stats.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" },
{ value: "14", label: "Editors trained" },
{ value: "0", label: "Support calls since launch" },
];
---
<div class="mx-auto max-w-6xl px-6 py-16">
<Stats heading="Results" text="What changed in the first months after launch." items={stats} listClass="@xl/stats:grid-cols-2 @3xl/stats:grid-cols-4">
<Badge slot="eyebrow">After launch</Badge>
</Stats>
</div>
```
## Props
### Stats
| 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. |
| `align` | `"start" \| "center"` | `"start"` | For recipes. The alignment of the header and of each stat. |
| `contentClass` | `string` | None | For recipes. Classes for the row that holds the header and the list. |
| `headerClass` | `string` | None | For recipes. Classes for the header (the eyebrow, the heading and the text). |
| `listClass` | `string` | None | For recipes. Classes for the list (the <dl>), such as its columns. It sits inside the stats container, so its classes can query it (@3xl/stats:...). |
| `itemClass` | `string` | None | For recipes. Classes for each stat (a <div> in the list), such as its hairline or its card. |
| `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.
Stats
FreeTo build your own stats layout: a few results as large numbers, each with a label and an optional line. For a ready layout, use StatsGrid or StatsCards.
- File
- Stats.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
Slots
The section is a shell: the eyebrow, the heading and the text always show in that order, then one list of stats, each a label and a large value with an optional line. The shell sets the type and the gaps; the recipes lay out the list and each stat. StatsGrid and StatsCards are recipes built on it.
This preview did not load.
main.astro
examples/stats/main.astro
---
import Badge from "@astronomic-dev/ui/components/Badge.astro";
import Stats from "@astronomic-dev/ui/components/Stats.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" },
{ value: "14", label: "Editors trained" },
{ value: "0", label: "Support calls since launch" },
];
---
<div class="mx-auto max-w-6xl px-6 py-16">
<Stats heading="Results" text="What changed in the first months after launch." items={stats} listClass="@xl/stats:grid-cols-2 @3xl/stats:grid-cols-4">
<Badge slot="eyebrow">After launch</Badge>
</Stats>
</div>Minimal · Light