Contact: split introduction and form
A contact introduction with response details and a labelled three-field form.
pnpm dlx shadcn@latest add @haze/contact-split-form---
import { Clock3, Mail } from "@lucide/astro";
import { cn } from "../../../lib/haze/utils";
import Button from "../ui/button.astro";
import Input from "../ui/input.astro";
import Textarea from "../ui/textarea.astro";
interface Props {
id?: string;
eyebrow?: string;
title?: string;
description?: string;
headingLevel?: 1 | 2 | 3;
email?: string;
responseTime?: string;
formAction?: string;
submitLabel?: string;
class?: string;
}
const {
id = "contact-split-form",
eyebrow = "Get in touch",
title = "Tell us what you're working on",
description = "Have a question or an idea? Share a little context and we'll help you find the right next step.",
headingLevel = 2,
email = "hello@example.com",
responseTime = "We usually reply within two business days.",
formAction = "",
submitLabel = "Send message",
class: className,
} = Astro.props;
const Heading = ({ 1: "h1", 2: "h2", 3: "h3" } as const)[headingLevel];
---
<section aria-labelledby={`${id}-title`} class={cn("bg-background px-6 py-20 sm:py-24", className)}>
<div class="mx-auto grid max-w-6xl gap-10 lg:grid-cols-2 lg:gap-24">
<div class="max-w-lg">
<p class="text-[0.6875rem]/4 font-medium tracking-wider text-muted-foreground uppercase">{eyebrow}</p>
<Heading id={`${id}-title`} class="mt-3 text-3xl/9 font-semibold tracking-tight text-balance text-foreground sm:text-4xl/11">{title}</Heading>
<p class="mt-4 text-base/7 text-pretty text-muted-foreground">{description}</p>
<div class="mt-8 grid gap-4 border-t border-border pt-6 text-sm/6 text-muted-foreground">
<p class="flex items-start gap-3"><Mail aria-hidden="true" class="mt-1 size-4 shrink-0" /><span>{email}</span></p>
<p class="flex items-start gap-3"><Clock3 aria-hidden="true" class="mt-1 size-4 shrink-0" /><span>{responseTime}</span></p>
</div>
</div>
<form action={formAction || undefined} method="post" class="grid gap-5 rounded-xl border border-border bg-card p-6 sm:p-8">
<div class="grid gap-1.5">
<label for={`${id}-name`} class="text-sm/5 font-medium text-foreground">Name</label>
<Input id={`${id}-name`} name="name" autocomplete="name" required />
</div>
<div class="grid gap-1.5">
<label for={`${id}-email`} class="text-sm/5 font-medium text-foreground">Email address</label>
<Input id={`${id}-email`} name="email" type="email" autocomplete="email" required />
</div>
<div class="grid gap-1.5">
<label for={`${id}-message`} class="text-sm/5 font-medium text-foreground">How can we help?</label>
<Textarea id={`${id}-message`} name="message" rows={5} required />
</div>
<div class="grid justify-items-start gap-3">
<Button type="submit" disabled={!formAction}>{submitLabel}</Button>
{!formAction && <p class="text-[0.8125rem]/5 text-muted-foreground">Demo form: add a form endpoint to receive messages.</p>}
</div>
</form>
</div>
</section>When to use
- Collecting a visitor's name, email and message for a team
- You can supply a real endpoint to receive form submissions
When not to use
- You only need an email signup; use newsletter-inline
Installation
Add the Haze registry to components.json once, then install Contact: split introduction and form with the shadcn CLI. Works in any Astro project with Tailwind CSS v4.
pnpm dlx shadcn@latest add @haze/contact-split-formnpx shadcn@latest add @haze/contact-split-formyarn dlx shadcn@latest add @haze/contact-split-formbunx --bun shadcn@latest add @haze/contact-split-formFirst time? Registry and theme setup
1. Add to components.json:
{
"registries": {
"@haze": "http://localhost:4329/r/{name}.json"
}
}2. Install the theme once: npx shadcn@latest add @haze/theme, then import it after Tailwind in your global CSS:@import "./haze.css";
API reference
| Prop | Type | Default | Description |
|---|---|---|---|
| id | string | "contact-split-form" | Unique ID prefix for the section and all its fields. |
| eyebrow | string | "Get in touch" | Label above the section heading. |
| title | string | demo heading | Heading above the contact details. |
| description | string | demo copy | Introductory contact copy. |
| headingLevel | 1 | 2 | 3 | 2 | Heading level for the section title. |
| string | "hello@example.com" | Displayed contact address; the default is an example. | |
| responseTime | string | demo response time | Expected response time shown alongside the email address. |
| formAction | string | "" | POST endpoint. With no endpoint, submission is disabled and the form is labelled as a demo. |
| submitLabel | string | "Send message" | Submit button text. |
| class | string | – | Additional classes on the section. |
Keyboard interactions
- Tab
- Move through the fields and, once configured, the submit button.
Accessibility
- All three required controls have visible labels and use native browser validation.
- The default preview announces that submission is unavailable until an endpoint is configured.
Notes for AI
Copy into Claude Code, Cursor, Codex or any coding agent. Agents can also read the Markdown version of this page.
Install and use
Install the Haze UI block "Contact: split introduction and form" with `npx shadcn@latest add @haze/contact-split-form`. If components.json has no "@haze" registry yet, add "registries": { "@haze": "http://localhost:4329/r/{name}.json" }. If src/styles/haze.css does not exist yet, run `npx shadcn@latest add @haze/theme` once and import it from the global stylesheet after Tailwind. The CLI stops at an overwrite question when a Haze file already exists and differs, even with --yes, and then installs nothing after it: read its output. If the user has not edited their Haze files, re-run with --overwrite to take the registry versions; if they have, ask them before overwriting. Then import ContactSplitForm from "@/components/haze/blocks/contact-split-form.astro" (or the relative path) and render it where it fits the page. Keep Haze token classes (bg-background, text-muted-foreground, border-border...) and never hardcode colors. Docs: http://localhost:4329/blocks/contact-split-form.md
Customize with real content
Adapt the Haze contact-split-form block for our product. Replace the demo values of these props with our real content: id, eyebrow, title, description, headingLevel, email, responseTime, formAction, submitLabel, class. Keep the layout, the heading level rules and these accessibility details: All three required controls have visible labels and use native browser validation. The default preview announces that submission is unavailable until an endpoint is configured. Do not add raw color classes; use the Haze tokens.
Choose the right block
Before using contact-split-form, check it fits: use it when collecting a visitor's name, email and message for a team; you can supply a real endpoint to receive form submissions. Avoid it when you only need an email signup; use newsletter-inline. Alternatives: @haze/newsletter-inline.
Dependencies
- npm: @lucide/astro
- @haze/button
- @haze/input
- @haze/textarea
- @haze/utils
- @haze/theme (one-time setup)
Source · Original Haze UI work.