Skip to content
Klarhimmel UI

Contact, form

Contact, form previewContact, form preview

Install

npx shadcn add @klarhimmel/contact-form
DetailsAbout, usage, props and more

Heading and contact details beside a simple message form. Presentation only: the page wires the submit.

Import

Import

import Block from '@/components/klarhimmel/blocks/contact-form';
Also called
  • contact/form
Category
A form, a booking panel or office details. The page wires the submit. New project? Set it up once: /get-started/installation.

Notes

When to use it

Heading and contact details on the left beside a message form on the right. Presentation only: the page wires the submit. For a list of addresses without a form, use contact-channels or contact-minimal.

Writing for it

- Details take up to four label and value pairs (40 and 120) in plain text, not links; keep to the phone, visit and hours people ask for. - Leave nameLabel empty to drop the name field and keep only email and message. messageLabel (40) names the last field. - messageType turns the last field into a single line: domain for a site address, url for a full link, email or text. Set messageName if your backend expects a field other than 'message'.

Watch out for

The sent and error texts are drawn only when the host sets status, usually after a redirect with ?sent=1. When status is sent, the fields are hidden and only the message shows. An empty messageLabel removes the last field.

Usage

The block in a page, with its default content (long lists shortened). Every prop is in the table below.

section.tsx
import { Theme } from '@/components/klarhimmel/theme/style';
import { BlockSurface } from '@/components/klarhimmel/blocks/surface';
import ContactForm from '@/components/klarhimmel/blocks/contact-form';

export default function Section() {
  return (
    <Theme theme="brand">
      <BlockSurface>
        <ContactForm props={{
          "eyebrow": "Name the topic",
          "title": "Ask what they want to tell you",
          "description": "Say in one sentence who reads the message and when they get a reply.",
          "details": [
            {
              "label": "First detail",
              "value": "hello@yourcompany.example",
              "href": "mailto:hello@yourcompany.example"
            },
            {
              "label": "Second detail",
              "value": "Give the street address and town"
            },
            {
              "label": "Third detail",
              "value": "Give the days and opening hours"
            }
          ],
          "nameLabel": "Full name",
          "emailLabel": "Your email",
          "messageLabel": "Your message",
          "submit": "Send",
          "consent": "Say in one line what the details are used for.",
          "messages": {
            "sent": "Thank them and say when they can expect a reply.",
            "error": "Say it failed and what they can do instead."
          },
          "errors": {
            "required": "Say this field is needed.",
            "email": "Say what a valid email address looks like.",
            "url": "Say what a valid web address looks like, with an example.",
            "domain": "Say what a site address looks like, with one."
          }
        }} />
      </BlockSurface>
    </Theme>
  );
}

Props

The type, default and text limit of every prop. On a real page, over-limit text is kept and checkSections flags it (Installation, Check a page before you ship); this live preview shows the default until it fits. The panel above edits all props.

PropTypeDefaultDescription
eyebrowstring'Name the topic'Text, up to 60 characters.
titlestring'Ask what they want to tell you'Text, up to 120 characters.
descriptionstring'Say in one sentence who reads the m…'Text, up to 300 characters.
details{ label, value, href, note }[]3 itemsList of up to 6. Each item: label, value, href (optional), note (optional).
nameLabelstring'Full name'Text, up to 40 characters. Optional; empty is not rendered.
emailLabelstring'Your email'Text, up to 40 characters.
phoneLabelstring-Text, up to 40 characters. Optional; empty is not rendered.
address{ street, postcode, city }-Fields: street (optional), postcode (optional), city (optional). Optional; empty is not rendered.
fields{ kind, label, name, options, required, placeholder, hint, after }[]-List of up to 30. Each item: kind ('heading' | 'text' | 'select' | 'radio' | 'checkboxes' | 'date' | 'number'), label, name (optional), options (optional), required (optional), placeholder (optional), hint (optional), after (optional). Optional; empty is not rendered.
messageLabelstring'Your message'Text, up to 80 characters.
messageType'textarea' | 'url' | 'domain' | 'email' | 'text'-One of 'textarea', 'url', 'domain', 'email', 'text'. Optional; empty is not rendered.
messageNamestring-Text, up to 40 characters. Optional; empty is not rendered.
errors{ required, email, url, domain }{…}Fields: required (optional), email (optional), url (optional), domain (optional). Optional; empty is not rendered.
submitstring'Send'Text, up to 40 characters.
consentstring'Say in one line what the details ar…'Text, up to 160 characters.
consentLinkLink-Optional; empty is not rendered.
consentRequiredboolean-Optional; empty is not rendered.
honeypotstring-Text, up to 40 characters. Optional; empty is not rendered.
actionstring-Text, up to 300 characters. Optional; empty is not rendered.
method'post' | 'get'-One of 'post', 'get'. Optional; empty is not rendered.
hidden{ }-Optional; empty is not rendered.
captchaboolean-Optional; empty is not rendered.
captchaSitekeystring-Text, up to 100 characters. Optional; empty is not rendered.
status'idle' | 'sent' | 'error'-One of 'idle', 'sent', 'error'. Optional; empty is not rendered.
messages{ sent, error }{…}Fields: sent, error. Optional; empty is not rendered.
headingLevel'1' | '2'-One of '1', '2'. Optional; empty is not rendered.