Vilqor

Stats Section with Count Up

Component

About

Big mono numbers on a quiet night sky that count up from zero as the band comes into view, with a serif heading, units in the accent and a short line under each. Part of Midnight, the full template on 21st.

Built with React and Tailwind. Copy the prompt and paste it into Claude Code, Cursor or Lovable: your agent adds Stats Section with Count Up to your project and fits it to your theme.

Code

How Stats Section with Count Up is used: the demo's code. The component's own source comes with a free account.

Usage.tsx

import { useSyncExternalStore, type CSSProperties } from "react"

import { MetricsBand } from "@/components/ui/metrics-band"

// Midnight by day: Fraunces heading, Geist text, Geist Mono figures, units and label in deep gold
const fonts =
  "@import url('https://fonts.googleapis.com/css2?family=Fraunces:ital,opsz,wght,SOFT@0,9..144,300..600,0..100;1,9..144,300..600,0..100&family=Geist:wght@400..600&family=Geist+Mono:wght@400..500&display=swap');"

const settings = {
  label: "This quarter",
  title: "The platform, in numbers.",
  countUp: true,
  stars: 0,
  paper: "#f7f5f0",
  band: "#ece8df",
  ink: "#141a2e",
  muted: "#4a5166",
  primary: "#a8803a",
}

// Midnight by night, the template's own palette
const night: Partial<typeof settings> = {
  paper: "#0b1020",
  band: "#070a16",
  ink: "#ece9e1",
  muted: "#a9afc4",
  primary: "#d9b77e",
}

// 21st marks its dark theme with .dark on <html>; the demo answers with Midnight by night
function useDark() {
  return useSyncExternalStore(
    (on) => {
      const watch = new MutationObserver(on)
      watch.observe(document.documentElement, { attributes: true, attributeFilter: ["class"] })
      return () => watch.disconnect()
    },
    () => document.documentElement.classList.contains("dark"),
    () => false,
  )
}

function day(s: typeof settings) {
  const t: Record<string, string> = {
    background: s.paper,
    foreground: s.ink,
    primary: s.primary,
    "muted-foreground": s.muted,
  }
  return {
    ...Object.fromEntries(Object.entries(t).flatMap(([k, v]) => [[`--${k}`, v], [`--color-${k}`, v]])),
    "--font-display": "Fraunces, ui-serif, Georgia, serif",
    "--font-sans": "Geist, ui-sans-serif, system-ui, sans-serif",
    "--font-mono": "'Geist Mono', ui-monospace, Menlo, monospace",
  } as CSSProperties
}

export default function Demo(props: Partial<typeof settings>) {
  const dark = useDark()
  const s = { ...settings, ...props, ...(dark ? night : {}) }
  return (
    <div className="flex min-h-svh w-full flex-col justify-center" style={{ ...day(s), fontFamily: "Geist, ui-sans-serif, system-ui, sans-serif", background: s.paper } as CSSProperties}>
      <style>{fonts}</style>
      <MetricsBand
        label={s.label}
        title={s.title}
        titleClassName="font-[350] [font-variation-settings:'SOFT'_50]"
        countUp={s.countUp}
        band={s.band}
        stars={dark ? 80 : s.stars}
        items={[
          { value: "2.4", unit: "B", label: "requests served without a hiccup" },
          { value: "99.98", unit: "%", label: "uptime across every region" },
          { value: "14", unit: "ms", label: "median response at the edge" },
          { value: "320", label: "teams shipping on it every week" },
        ]}
      />
    </div>
  )
}

Dependencies

More by Vilqor

View all
  • 3D Glass Cube Hero

    3D Glass Cube Hero

    210
  • Footer with Big Wordmark

    Footer with Big Wordmark

    163
  • Guilloche Background Pattern

    Guilloche Background Pattern

    8
  • Card Carousel to Grid

    Card Carousel to Grid

  • AI Email Reply with Tones

    AI Email Reply with Tones

  • AI Memory Timeline

    AI Memory Timeline

  • Use Cases Tabs Section

    Use Cases Tabs Section

  • Pricing Section with Toggle

    Pricing Section with Toggle