Skip to content

Block 47 of 297

Contact Form

Plain HTML contact form with name, email, optional phone, topic menu and message beside a contact details sidebar.

Puck key
ContactFormBlock
Export
contactFormBlock
React component
<ContactForm />
Path
components/puck/contact-form-block.tsx
Dependencies
None
License
MIT

About this block

When to use it, how to write for it, and what to change in the code.

What it's for

A general contact form with full name, email, optional phone, a required topic menu and a message box, set beside a sidebar of phone, email and mailing address. It posts with plain HTML to any endpoint you choose. On desktop the sidebar sticks in view as the form scrolls; on phones it moves below the form.

  • The main Contact page for a nonprofit, district or agency
  • A department page that routes questions to the right staff by topic
  • A partnership or media inquiry page with direct contact details alongside
Writing the content
  • Topics fills the "What's this about?" menu (one to twelve). Name them after who handles them.
  • The form sends fixed field names: name, email, phone, topic and message.
  • Use Message hint to ask for details like a receipt number. Messages need at least 10 characters.
  • Leave every sidebar field blank to hide the sidebar. Phone is linked for tap-to-call, and each Address line is its own row.
Accessibility
  • Every field has a visible label, optional fields say so, and a line at the top states the rest are required.
  • Inputs use autocomplete values, and the message hint is tied to its field with aria-describedby.
  • The sidebar is an aside labelled by its heading, with details in a description list.
Customizing the code
  • Shared input styling is in the inputClass and labelClass constants; the focus ring is ring-indigo-600.
  • To add a field, copy a label and input pair and give it a name your endpoint expects.

Editor fields

What content editors see in the P1 sidebar when they select this block.

  • Headingtext
  • Heading levelselect
  • Introtextarea
  • Form action URLtext
  • Topicsarray
  • Message hinttext
  • Button texttext
  • Privacy notetextarea
  • Sidebar headingtext
  • Phonetext
  • Phone hourstext
  • Emailtext
  • Addresstextarea
  • Sidebar notetextarea