Calm motion: animations on this site only fade, with no movement
Contact form
A contact form with the name, the email, the topic, the message, and a clear result
Lets visitors of a company site write to the team without an email program.
Basic
- The form has a name, an email address, and a message.
topicsadds a menu of topics. - Send checks the fields. Each error shows under its field and is linked to it, and the focus moves to the first wrong field.
- If all is correct, the form emits
submitwith the name, the email, the topic, and the message. You send them to your server. stategives the result back:sendingchanges the button text,sentreplaces the form with a thank-you line, anderrorshows an alert above the button. In the example, a message with "fail" in it fails.- Topics can load after the form shows. The form then picks the first topic, and it keeps a topic that is still in the list.
- A field that people do not see catches simple spam bots. If a bot fills it, the form sends nothing. Check messages on your server too.
- Change the words with
labelsor a label pack. The API table lists the keys.
Usage
ts
import { BlessContactForm } from "blessing-ui";API
Props
| Name | Type | Default | Description |
|---|---|---|---|
topics | string[] | [] | the topics of the menu; without them, the form has no topic |
state | "idle" | "error" | "sending" | "sent" | "idle" | your part after the submit event: sending, sent, or error |
labels | Partial<{ name: string; email: string; topic: string; message: string; send: string; sending: string; sent: string; error: string; needName: string; needEmail: string; needMessage: string; }> | — |
Events
| Name | Payload | Description |
|---|---|---|
submit | [message: BlessContactMessage] |