GitHub

Contact Form

Block
Contact form with name, email, and message fields

Basic Usage

Loading...

Installation

pnpm add @corew500/ui

Usage

import { ContactForm } from "@corew500/ui/blocks/contact-form"

<ContactForm>Content</ContactForm>

API Reference

Props

PropTypeDefaultDescription
onFormSubmit(data: ContactFormData) => voidCalled when the form is submitted with form data
loadingenumfalseWhether the form is in a loading state
successenumfalseWhen true, shows success state instead of form
titlestringSend us a messageCustom title for the card header
descriptionstringFill out the form below and we'll get back to you as soon as possible.Custom description for the card header
successTitlestringMessage Sent!Title shown in success state
successDescriptionstringThank you for reaching out. We'll get back to you shortly.Description shown in success state
successSubDescriptionstringSecondary description shown in success state
successActionenumOptional action element for success state (e.g., "Send another message" button)
submitLabelstringSend MessageText for the submit button
loadingLabelstringSending...Text shown on submit button while loading
fields{ company?: boolean; subject?: boolean; }{}Which optional fields to show
placeholders{ firstName?: string; lastName?: string; email?: string; company?: string; subject?: string; message?: string; }{}Placeholder text for fields
labels{ firstName?: string; lastName?: string; email?: string; company?: string; subject?: string; message?: string; }{}Field labels (for i18n support)
errorsRecord<string, string>{}Validation error messages keyed by field name

Accessibility

Keyboard Navigation

  • All interactive elements are keyboard navigable
  • Enter key submits the form (except in textarea)

Screen Readers

  • Required fields are marked with asterisk and proper aria-required
  • Error messages are linked via aria-describedby and aria-invalid
  • Error messages use role="alert" for screen reader announcements
  • Success state uses role="status" and aria-live="polite"

Additional

  • - All form fields have proper label associations via htmlFor/id
  • Submit button shows loading state with disabled attribute

Localization

Translatable Content

  • - Component accepts pre-resolved translated strings
  • All user-facing text is customizable via props:
  • `title`, `description` - Form header text
  • `successTitle`, `successDescription`, `successSubDescription` - Success state text
  • `labels` - Field labels (firstName, lastName, email, company, subject, message)
  • `submitLabel`, `loadingLabel` - Button text
  • No internal text hardcoding - all strings flow through props with English defaults

Additional

  • `placeholders` - Input placeholders for all fields
  • Validation errors via `errors` prop