A centred heading over four figures, each with an accent line and a link.

Last updated

Open block
Show code
---
/**
 * Simple accent line: A centred heading over four figures, each with an accent line and a link.
 *
 * @block metrics
 * @order 7
 */
import { ArrowRight, Zap } from '@lucide/astro'
import Section from '@/components/apogee/Section/Section.astro'
import SectionHeader from '@/components/apogee/SectionHeader/SectionHeader.astro'
import FeaturedIcon from '@/components/apogee/FeaturedIcon/FeaturedIcon.astro'
import Link from '@/components/apogee/Link/Link.astro'
import { plain } from '@/components/apogee/sections/_shared/spine.ts'
import type { MetricsContent, MetricItem } from '@/components/apogee/sections/_shared/metrics.ts'

/** @composable */
interface Props extends MetricsContent {
  /** The figures; a figure's link shows when it has an `href`. @category content */
  items?: (MetricItem & { href?: string; linkLabel?: string })[]
}

const {
  heading = 'Build something great',
  description = 'Everything you need to build modern interfaces and great products.',
  items = [
    { value: '400+', label: 'Projects completed', href: '#', linkLabel: 'View projects' },
    { value: '600%', label: 'Return on investment', href: '#', linkLabel: 'Read the study' },
    { value: '10k', label: 'Global downloads', href: '#', linkLabel: 'Download now' },
    { value: '200+', label: 'Five-star reviews', href: '#', linkLabel: 'View reviews' },
  ],
} = Astro.props
---

<Section spacing="large">
  <div class="flex flex-col gap-12 md:gap-16">
    <div class="flex flex-col items-center gap-4 md:gap-6">
      <FeaturedIcon theme="light" color="primary" size="xlarge"><Zap /></FeaturedIcon>
      <SectionHeader heading={plain(heading)} description={description ?? undefined} size="large" align="center" />
    </div>
    <dl class="flex flex-col gap-10 md:flex-row md:justify-between md:gap-8">
      {items.map((s) => (
        <div class="border-t-2 pt-6 md:border-t-0 md:border-s-2 md:ps-6 md:pt-0 border-primary">
          <div class="flex flex-col gap-3">
            <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.href && <dd class="order-4 mt-2"><Link href={s.href} color="primary" class="inline-flex items-center gap-1 font-semibold">{s.linkLabel}<ArrowRight class="size-4 rtl:-scale-x-100" aria-hidden="true" /></Link></dd>}
          </div>
        </div>
      ))}
    </dl>
  </div>
</Section>

Add

npx @ava-ui/apogee add metrics/simple-accent-line

This copies the block to src/components/apogee/blocks/metrics/ with everything it uses: FeaturedIcon, Link, 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.