A large heading with an underlined phrase, a line and two buttons over a wide photo, on the brand colour.

Last updated

Open block
Show code
---
/**
 * Simple text 02: A large heading with an underlined phrase, a line and two buttons over a wide photo, on the brand colour.
 *
 * @block hero
 * @order 41
 */
import { CirclePlay } from '@lucide/astro'
import Section from '@/components/apogee/Section/Section.astro'
import Heading from '@/components/apogee/Heading/Heading.astro'
import Button from '@/components/apogee/Button/Button.astro'
import Image from '@/components/apogee/Image/Image.astro'
import { accentRuns, type HeroContent } from '@/components/apogee/sections/_shared/spine.ts'

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

const {
  heading = 'We design *digital experiences* that make people happy',
  description = "We're a full-service design and development studio. We help teams build websites people enjoy using.",
  primaryAction = { label: 'Get in touch', href: '#' },
  secondaryAction = { label: 'Showreel', href: '#' },
  media = { src: 'https://picsum.photos/seed/apogee-hero-41/1600/800', alt: '', width: 1600, height: 800 },
} = Astro.props
---

<Section spacing="large" background="primary">
  <div class="flex flex-col gap-8 md:gap-12">
    <div class="flex flex-col gap-4 md:gap-6">
      <Heading as="h1" size="display" class="max-w-4xl text-balance">{accentRuns(heading).map((r) => (r.accent ? <span class="underline decoration-4 underline-offset-8 decoration-current">{r.text}</span> : r.text))}</Heading>
      {description && <p class="max-w-2xl text-lg md:text-xl opacity-85">{description}</p>}
    </div>
    {(primaryAction || secondaryAction) && (
      <div class="flex flex-col-reverse gap-3 sm:flex-row ">
        {secondaryAction && <Button href={secondaryAction.href} size="large" variant="outline" color="neutral" class="border-current! bg-transparent! text-inherit! shadow-none!"><CirclePlay slot="start" aria-hidden="true" />{secondaryAction.label}</Button>}
        {primaryAction && <Button href={primaryAction.href} size="large" color="neutral">{primaryAction.label}</Button>}
      </div>
    )}
  </div>
  {media && <Image src={media.src} alt={media.alt} width={media.width} height={media.height} fit="cover" radius="xl" loading="eager" class="mt-12 h-60 w-full md:mt-16 md:h-129" />}
</Section>

Add

npx @ava-ui/apogee add hero/simple-text-02

This copies the block to src/components/apogee/blocks/hero/ with everything it uses: Button, Heading, Image, Section. 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 the page’s h1; the items below are one level down.
  • Photos that only decorate have an empty alt; give yours one when it carries meaning.