A heading and actions beside four figures, each with an icon.

Last updated

Open block
Show code
---
/**
 * Simple with actions 02: A heading and actions beside four figures, each with an icon.
 *
 * @block metrics
 * @order 12
 */
import { ChartLine, CirclePlay, CloudDownload, Star, Zap } from '@lucide/astro'
import Section from '@/components/apogee/Section/Section.astro'
import SectionHeader from '@/components/apogee/SectionHeader/SectionHeader.astro'
import Button from '@/components/apogee/Button/Button.astro'
import FeaturedIcon from '@/components/apogee/FeaturedIcon/FeaturedIcon.astro'
import { plain } from '@/components/apogee/sections/_shared/spine.ts'
import type { MetricsContent } from '@/components/apogee/sections/_shared/metrics.ts'

const icons = [Zap, ChartLine, CloudDownload, Star]

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

const {
  heading = 'Build something great',
  description = 'Everything you need to build modern interfaces and great products.',
  primaryAction = { label: 'Get started', href: '#' },
  secondaryAction = { label: 'Demo', href: '#' },
  items = [
    { value: '400+', label: 'Projects completed' },
    { value: '600%', label: 'Return on investment' },
    { value: '10k', label: 'Global downloads' },
    { value: '200+', label: 'Five-star reviews' },
  ],
} = Astro.props
---

<Section spacing="large">
  <div class="grid gap-12 lg:grid-cols-2 lg:gap-16">
    <div class="flex flex-col gap-8">
      <SectionHeader heading={plain(heading)} description={description ?? undefined} size="large" />
      {(primaryAction || secondaryAction) && (
        <div class="flex flex-col gap-3 sm:flex-row">
          {secondaryAction && <Button href={secondaryAction.href} size="large" variant="outline" color="neutral"><CirclePlay slot="start" aria-hidden="true" />{secondaryAction.label}</Button>}
          {primaryAction && <Button href={primaryAction.href} size="large">{primaryAction.label}</Button>}
        </div>
      )}
    </div>
    <ul role="list" aria-label="Key figures" class="grid gap-x-8 gap-y-10 md:grid-cols-2 md:gap-y-12">
      {items.map((s, i) => { const Icon = icons[i % icons.length]!; return (
        <li class="flex flex-col items-center gap-4 text-center md:flex-row md:items-start md:text-start">
          <FeaturedIcon theme="light" color="primary" size="large" class="shrink-0"><Icon /></FeaturedIcon>
          <div class="flex flex-col gap-3">
            <p class="text-5xl font-semibold tracking-tight tabular-nums md:text-6xl text-primary">{s.value}</p>
            <p class="text-lg font-semibold">{s.label}</p>
          </div>
        </li>
      )})}
    </ul>
  </div>
</Section>

Add

npx @ava-ui/apogee add metrics/simple-with-actions-02

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