Skip to content
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. topics adds 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 submit with the name, the email, the topic, and the message. You send them to your server.
  • state gives the result back: sending changes the button text, sent replaces the form with a thank-you line, and error shows 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 labels or a label pack. The API table lists the keys.

Usage ​

ts
import { BlessContactForm } from "blessing-ui";

API ​

Props

NameTypeDefaultDescription
topicsstring[][]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
labelsPartial<{ name: string; email: string; topic: string; message: string; send: string; sending: string; sent: string; error: string; needName: string; needEmail: string; needMessage: string; }>—

Events

NamePayloadDescription
submit[message: BlessContactMessage]

Released under the MIT License. Character names and artwork belong to their owners.