A centred heading with a badge over three figure cards on a photo.

Last updated

Open block
Show code
---
/**
 * Image with cards 01: A centred heading with a badge over three figure cards on a photo.
 *
 * @block metrics
 * @order 3
 */
import Section from '@/components/apogee/Section/Section.astro'
import SectionHeader from '@/components/apogee/SectionHeader/SectionHeader.astro'
import Badge from '@/components/apogee/Badge/Badge.astro'
import Image from '@/components/apogee/Image/Image.astro'
import { plain } from '@/components/apogee/sections/_shared/spine.ts'
import type { MetricsContent } from '@/components/apogee/sections/_shared/metrics.ts'

/** @composable */
interface Props extends MetricsContent {}

const {
  eyebrow = 'Launch faster',
  heading = 'Build something great',
  description = 'Everything you need to build modern interfaces and great products.',
  items = [
    { value: '400+', label: 'Projects completed', description: "We've helped build over 400 projects with teams of every size." },
    { value: '600%', label: 'Return on investment', description: "Customers report an average return of about 600%." },
    { value: '10k', label: 'Global downloads', description: "Our starter kit has been downloaded over 10k times." },
  ],
  media = { src: 'https://picsum.photos/seed/apogee-metrics-1/1600/900', alt: '', width: 1600, height: 900 },
} = Astro.props
---

<Section spacing="large">
  <div class="flex flex-col items-center gap-12 md:gap-16">
    <div class="flex flex-col items-center gap-4">
      {eyebrow && <Badge color="primary" rounded>{eyebrow}</Badge>}
      <SectionHeader heading={plain(heading)} description={description ?? undefined} size="large" align="center" />
    </div>
    <div class="relative isolate overflow-hidden rounded-2xl px-6 py-8 md:p-16">
      {media && <div class="absolute inset-0 -z-10"><Image src={media.src} alt={media.alt} width={media.width} height={media.height} fit="cover" class="size-full" /></div>}
      <dl class="grid gap-8 md:grid-cols-2 lg:grid-cols-3">
        {items.map((s) => (
          <div class="rounded-2xl bg-page/85 p-6 shadow-raised ring-1 ring-inset ring-neutral backdrop-blur-lg">
            <div class="flex flex-col gap-3 items-center text-center">
              <dt class="order-2 text-lg font-semibold">{s.label}</dt>
              <dd class="order-1 text-5xl font-semibold tracking-tight tabular-nums md:text-6xl text-primary">{s.value}</dd>
              {s.description && <dd class="order-3 text-neutral-faded">{s.description}</dd>}
            </div>
          </div>
        ))}
      </dl>
    </div>
  </div>
</Section>

Add

npx @ava-ui/apogee add metrics/image-with-cards-01

This copies the block to src/components/apogee/blocks/metrics/ with everything it uses: Badge, Image, Section, SectionHeader. Every piece of copy is a prop, with the sample copy as its default. Pass yours, or null to hide a part; see copy is props.

Accessibility

  • The heading is an h2 by default, so the block slots into a page under its h1; item titles are one level down.
  • Photos that only decorate have an empty alt; give yours one when it carries meaning.