A centred heading over a contact form.

Last updated

Open block
Show code
---
/**
 * Simple form: A centred heading over a contact form.
 *
 * @block contact
 * @order 1
 */
import Section from '@/components/apogee/Section/Section.astro'
import SectionHeader from '@/components/apogee/SectionHeader/SectionHeader.astro'
import ContactForm from '@/components/apogee/ContactForm/ContactForm.astro'
import { plain } from '@/components/apogee/sections/_shared/spine.ts'
import type { ContactContent } from '@/components/apogee/sections/_shared/contact.ts'

/** @composable */
interface Props extends ContactContent {
  /** 1 when the block opens a page; its items move one level down with it. */
  headingLevel?: 1 | 2
}
const {
  headingLevel = 2,
  eyebrow = 'Contact us',
  heading = 'Get in touch',
  description = "We'd love to hear from you. Please fill out this form.",
  action,
  method,
  submitLabel = 'Send message',
} = Astro.props
---

<Section spacing="large" containerWidth="small">
  <SectionHeader headingLevel={headingLevel} eyebrow={eyebrow ?? undefined} heading={plain(heading)} description={description ?? undefined} align="center" class="mb-12" />
  <div class="mx-auto w-full max-w-lg"><ContactForm action={action} method={method} submitLabel={submitLabel} /></div>
</Section>

Add

npx @ava-ui/apogee add contact/simple-form

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