@molecule/app-contact-form-vue
Feature · contact-form · App (browser) · v1.1.3 · Apache-2.0
Generic name + email + message form with submit handler
npm install @molecule/app-contact-form-vueHow it works
@molecule/app-contact-form-vue is a ready-made contact-form feature for the app (browser) side. It composes the core interfaces it needs, so it works with whichever providers your app has bonded.
import { createApp, defineComponent, h } from 'vue'
import { ContactForm } from '@molecule/app-contact-form-vue'
const Contact = defineComponent({
setup() {
return () =>
h(
ContactForm,
{
title: 'Get in touch',
description: "We'll respond within one business day.",
onSubmit: async (values) => {
await api.sendContactMessage(values)
},
},
{
successContent: () => [h('p', "Thanks! We'll be in touch soon.")],
},
)
},
})
createApp(Contact).mount('#app')Works with: @molecule/app-ui, @molecule/app-ui-vue, @molecule/app-vue
Reference
Vue generic contact form (name + email + message + extras).
Exports <ContactForm> and ContactFormValues type — the Vue counterpart of
@molecule/app-contact-form-react: the same props (React names) and the same
DOM for the same input, so an app switches framework by changing only the
package name in its imports.
Auto-generated, AI-first package reference for the molecule.dev ecosystem. It is written to be read by coding agents as much as by people, and is generated from this package's source — edit
src/index.tsJSDoc, not this file.
Quick Start
import { createApp, defineComponent, h } from 'vue'
import { ContactForm } from '@molecule/app-contact-form-vue'
const Contact = defineComponent({
setup() {
return () =>
h(
ContactForm,
{
title: 'Get in touch',
description: "We'll respond within one business day.",
onSubmit: async (values) => {
await api.sendContactMessage(values)
},
},
{
successContent: () => [h('p', "Thanks! We'll be in touch soon.")],
},
)
},
})
createApp(Contact).mount('#app')
Type
feature
Installation
npm install @molecule/app-contact-form-vue @molecule/app-ui @molecule/app-ui-vue @molecule/app-vue vue
API
Interfaces
ContactFormValues
Shape of values collected by the contact form and passed to onSubmit.
interface ContactFormValues {
name: string
email: string
message: string
/** App-supplied additional fields. */
[key: string]: string
}
ContactFormProps
Props accepted by the ContactForm component.
interface ContactFormProps {
/** Called with the form values on submit. Return a Promise to block double-submit. */
onSubmit: (values: ContactFormValues) => void | Promise<void>
/** Form heading. Passed as a prop or as the same-named slot — both work. */
title?: VNodeChild
/** Optional supporting copy under the heading (prop or same-named slot). */
description?: VNodeChild
/** Custom submit-button label (prop or same-named slot). */
submitLabel?: VNodeChild
/** Rendered when the form successfully submits (prop or same-named slot). */
successContent?: VNodeChild
/** Extra fields rendered above the message textarea (prop or same-named slot). */
extraFields?: VNodeChild
/** Extra classes. */
className?: string
}
Constants
ContactForm
Generic name + email + message contact form with submit handling and
success state. extraFields slot lets apps add domain-specific inputs
(subject, phone, agent id, etc.).
Always pass successContent: without it the form clears silently after a
successful submit with no user feedback. If onSubmit rejects, the thrown
Error.message is shown verbatim below the form — throw translated,
user-safe messages.
const ContactForm: DefineComponent<
ExtractPropTypes<{
onSubmit: {
type: PropType<(values: ContactFormValues) => void | Promise<void>>
required: true
}
title: null
description: null
submitLabel: null
successContent: null
extraFields: null
className: StringConstructor
}>,
() => VNodeChild,
{},
{},
{},
ComponentOptionsMixin,
ComponentOptionsMixin,
{},
string,
PublicProps,
Readonly<
ExtractPropTypes<{
onSubmit: {
type: PropType<(values: ContactFormValues) => void | Promise<void>>
required: true
}
title: null
description: null
submitLabel: null
successContent: null
extraFields: null
className: StringConstructor
}>
> &
Readonly<{}>,
{},
{},
{},
{},
string,
ComponentProvideOptions,
true,
{},
any
>
props— Component props (seeContactFormProps).
Returns: The contact form component.
Injection Notes
Requirements
Peer dependencies:
@molecule/app-ui^1.0.1@molecule/app-ui-vue^1.1.0@molecule/app-vue^3.13.0 || ^4.0.0vue^3.4.0
Runtime Dependencies
@molecule/app-ui@molecule/app-ui-vue@molecule/app-vuevue
onSubmit receives ONLY { name, email, message } — inputs rendered via
the extraFields slot are displayed but NOT collected; own their state in
the parent and merge them inside your onSubmit (or a wrapping form).
Always pass successContent: without it the form clears silently after a
successful submit with no user feedback. If onSubmit throws, the thrown
Error.message is shown verbatim below the form — throw translated,
user-safe messages. Placeholders/buttons use contactForm.* i18n keys
(companion bond: @molecule/app-locales-contact-form).
Node-valued props arrive as a prop AND a same-named slot
(title, description, submitLabel, successContent, extraFields);
components accept either.
Translations
Translation strings are provided by @molecule/app-locales-contact-form.