Skip to content
themes.dev
    Style: Wireframe

    Blocks · Marketing

    Stats row

    A section header and three or four figures in a row, each a large value over its label; a description list with tabular numerals.

    26% of 289 about pages and 20% of 671 home pages we studied have a stats section.

    In numbers

    Fast, and boring in the good way

    median time from push to live
    42 s
    uptime over the last twelve months
    99.98%
    teams deploying every week
    1,200+
    regions, with more on the way
    3

    Both previews render the same markup; the HTML tab below is that markup without a framework.

    Install

    React
    npx shadcn@latest add https://www.themes.dev/ui/r/stats-row.json
    Astro
    npx shadcn@latest add https://www.themes.dev/ui/r/astro/stats-row.json

    Or copy the files below into your project. They need clsx, tailwind-merge and the components they import, and the themes.dev UI theme. The HTML needs only the compiled CSS.

    stats-row.classes.ts
    /** Stats row: a section header and three or four figures in one row, each a large value over its label, with a rule
     *  above it (figures are data, and data keeps its lines). A description list: the label is the term and comes first in
     *  the DOM, the value is shown above it with flex-col-reverse. Two across on a phone, the full row from 48rem. Figures
     *  use tabular numerals so a row of them lines up. */
    export const statsRow = {
      root: '@container bg-background px-6 py-16 text-foreground @3xl:py-24',
      inner: 'mx-auto flex max-w-6xl flex-col gap-12',
      list: (count: number) => ['m-0 grid grid-cols-2 gap-x-6 gap-y-10', count === 3 ? '@3xl:grid-cols-3' : '@3xl:grid-cols-4', '@3xl:gap-x-10'].join(' '),
      stat: 'flex min-w-0 flex-col-reverse justify-end gap-2 border-t pt-5',
      // 30px on a narrow block so a value like 99.98% fits its half of a phone row; 36px from 24rem, 48px from 48rem.
      value: 'm-0 text-3xl font-semibold tracking-[-0.04em] tabular-nums @sm:text-4xl @3xl:text-5xl',
      label: 'text-base text-pretty text-muted-foreground',
    };
    
    export type Stat = { value: string; label: string };
    export type StatsRowContent = {
      kicker?: string;
      title: string;
      description?: string;
      stats: Stat[];
      /** Unique on the page; ids the heading. */
      id: string;
    };
    stats-row.tsx
    import { SectionHeader } from '@/components/ui/section-header';
    import { cn } from '@/lib/utils';
    import { statsRow as c, type StatsRowContent } from './stats-row.classes';
    
    export type StatsRowProps = StatsRowContent & { className?: string };
    
    /** A section header and three or four figures in a row, each a large value over its label. */
    export function StatsRow({ kicker, title, description, stats, id, className }: StatsRowProps) {
      return (
        <section aria-labelledby={`${id}-title`} className={cn(c.root, className)}>
          <div className={c.inner}>
            <SectionHeader id={`${id}-title`} kicker={kicker} title={title} description={description} />
            <dl className={c.list(stats.length)}>
              {stats.map((s) => (
                <div key={s.label} className={c.stat}>
                  <dt className={c.label}>{s.label}</dt>
                  <dd className={c.value}>{s.value}</dd>
                </div>
              ))}
            </dl>
          </div>
        </section>
      );
    }