Simple with actions 02
A heading and actions beside four figures, each with an icon.
Last updated
---
/**
* 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>
Show codeHide 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
h2by default, so the block slots into a page under itsh1; item titles are one level down.
Related
SectionHeaderEyebrow, heading and description at the top of a section or an app page, with actions, a divider and the level, alignment and colours every section shares.
Featured iconAn icon in a tinted tile, the glyph that leads an empty state, an alert, a stat or a feature card.
StatsHeadline numbers in a row or as cards.