React Contact Form
ContactForm is a React contact form block with name, email and message fields on glass, inline validation, a button that glows while sending and a success seal. It works with a plain onSubmit or react-hook-form.
npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/contact-form.jsonContact
Talk to us
Questions, feedback or a project in mind. We reply within one working day.
ContactFormdefaultContactFormLabels
Plain onSubmit
Submit it empty to see the messages and the focus move, then fill it in. onSubmit returns a promise, so the button shows its loading light until it settles; throw from it to show an error under the form.
Contact
Talk to us
Questions, feedback or a project in mind. We reply within one working day.
import { ContactForm } from "@/components/sheenui/blocks/contact-form";
// Package build (after the first npm release, or a packed tarball): import { ContactForm } from "@sheenui/theme";
// Your call; throw to show the error under the form
async function sendMessage(values: { name: string; email: string; message: string }) {
const res = await fetch("/api/contact", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(values),
});
if (!res.ok) throw new Error("We could not send that. Try again in a minute.");
}
export function Example() {
return (
<ContactForm
eyebrow="Contact"
title="Talk to us"
description="Questions, feedback or a project in mind. We reply within one working day."
onSubmit={async (values) => {
await sendMessage(values);
}}
/>
);
}Files to copy
11 folders · 16 files · 4 packages
- From
theme/src/ blocks/{contact-form.tsx, icons.tsx}components/button/components/glass-card/components/input/components/spinner/components/status-icons/components/textarea/hooks/{use-controllable.ts, use-latest.ts, use-magnetic.ts, use-media-query.ts, use-preferences.ts}motion/{gate.ts, light-follower.ts, tokens.ts}lib/{cn.ts, field-size.ts, form.ts, heading.ts, state-light.tsx, warn-once.ts}styles/
- shadcn CLI
npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/contact-form.jsonRegistry item: contact-form. The styles need the Tailwind v4 glass UI setup.- Packages
pnpm add @base-ui/react clsx motion tailwind-merge
With react-hook-form
validate={false} turns the block's own checks off. fieldProps takes register(...) for each field, errors takes formState.errors, and status follows isSubmitting and isSubmitSuccessful. The state light and the success seal work the same.
Write to us
import { useForm } from "react-hook-form";
import { ContactForm, type ContactFormStatus, type ContactFormValues } from "@/components/sheenui/blocks/contact-form";
// Package build (after the first npm release, or a packed tarball): import { ContactForm, type ContactFormStatus, type ContactFormValues } from "@sheenui/theme";
declare function sendMessage(values: ContactFormValues): Promise<void>;
export function Example() {
const { register, handleSubmit, reset, formState } = useForm<ContactFormValues>();
const { errors, isSubmitting, isSubmitSuccessful } = formState;
const status: ContactFormStatus = isSubmitting ? "submitting" : isSubmitSuccessful ? "success" : "idle";
return (
<ContactForm
title="Write to us"
validate={false}
status={status}
errors={{ name: errors.name?.message, email: errors.email?.message, message: errors.message?.message }}
fieldProps={{
name: register("name", { required: "Enter your name." }),
email: register("email", {
required: "Enter your email.",
pattern: { value: /^\S+@\S+\.\S+$/, message: "Enter a valid email address." },
}),
message: register("message", { required: "Write a message.", minLength: { value: 10, message: "Write at least 10 characters." } }),
}}
onSubmit={() => handleSubmit(sendMessage)()}
onReset={() => reset()}
/>
);
}Props
ContactFormLabels keys and English defaults (14)
Keyboard
Accessibility
- A real <form> with noValidate. Errors are visible text linked with aria-describedby; a failed check moves focus to the first invalid field.
- The success view is a status region and receives focus; the outcome is always text, never light alone.
- The form and the success view share one grid cell, so the card never changes height.
- The button glows while sending (state light) and the seal's check is drawn once. Reduced motion: the seal fades in and the check appears at once.
All exports on this page
ContactForm— A contact form on glass: name, email and a message with inline validation, a loading button and a success seal that lights green.defaultContactFormLabels— The English ContactFormLabels used when labels is omitted; a partial labels prop is merged over it.
When to use the contact form
- Use ContactForm on a contact or support page, with onSubmit(values) returning a promise so the button shows its loading light and a thrown error appears under the form.
- Use it beside react-hook-form by passing validate={false}, fieldProps from register(...), errors from formState.errors and a status derived from isSubmitting and isSubmitSuccessful.
- Use the aside slot for an address, hours or a map beside the form on a wide block, and eyebrow, title and description for the heading.
- Skip it for a long multi-step form; the Stepper and Field components are built for that, while ContactForm is three fields and a message.
- Pair it with FaqSection above it and SiteFooter below, and send the message from your server with a spam check rather than from the browser alone.
Frequently asked questions
Related pages
20 blocks pages in all: browse them on All blocks.
By Lokendra Singh Rathore (GitHub, opens in a new tab). Published , updated .